开发者

Arithmetic operators and function calling in C

开发者 https://www.devze.com 2022-12-31 20:35 出处:网络
I\'m not quite sure why I can\'t do double a = (double) my_Function(45) / 2048 / 2340 / 90; printf(\"%.4f\",a); // prints out 0.00

I'm not quite sure why I can't do

double a = (double) my_Function(45) / 2048 / 2340 / 90;
printf("%.4f",a); // prints out 0.00

But instead I have to use one more variable as:

开发者_StackOverflow
double a = (double) my_Function(45);
double b = a  / 2048 / 2340 / 90;
printf("%.4f",b);  // prints out the correct value


What does my_Function return? Perhaps your answer is less than 10^(-4).


It comes down to order of operations.

You basically are doing this in the first line

double a = (double)(my_Function(45) / 2048 / 2340 / 90);
0

精彩评论

暂无评论...
验证码 换一张
取 消