質問

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?

役に立ちましたか?

解決

It is the same number. It is the so-called scientific representation of floating point numbers. You can read more about it here: http://www.learncpp.com/cpp-tutorial/25-floating-point-numbers/

他のヒント

7.8125E-4 and 0.00078125 are the same as e-4 means x10^-4 (division by 10000). So they are identical in maths point of view.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top