문제

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