0

Code:

float cordsStepAmountHeight;
float cordsStepAmountWidth;

coordStepAmountHeight=(2.0f/height);
coordStepAmountWidth=(2.0f/width);

Where width is 2560 and height is 1504 (the resolution of my device).

After the calculation, the value of coordStepAmountHeight is 0.0013297872 which is correct but cordsStepAmountWidth is coming out as 7.8125E-4 (When I believe is it should be 0.00078125)

Why is coordStepAmountWidth coming out like this? Is it something to do with the variable being declared as a float and not being able to cope with the calculation or something else?

4

2 回答 2

1

是同一个号码。就是所谓的浮点数的科学表示。你可以在这里阅读更多关于它的信息:http: //www.learncpp.com/cpp-tutorial/25-floating-point-numbers/

于 2013-03-21T18:51:37.760 回答
0

7.8125E-4 和 0.00078125 与e-4相同,表示 x10^-4(除以 10000)。因此,它们在数学角度上是相同的。

于 2013-03-21T18:50:30.213 回答