Re: numeric issue: 0.95 - 0.05 == 0.8499996



~kurt schrieb:
Christian <fakemail@xxxxxx> wrote:

but around 1 the precision of floats should be much higher .. I could
understand this "mistake" if he subtracted 3 times 0.05f

This is about the inability to accurately represent decimal numbers
in binary format. 8/9 is close to 1 - not a large or small number.
But, you can not represent it in decimal format with a finite number
of digits. In the same way, you can not represent various finite decimal
numbers in binary with a finite number of 1's and 0's.

- Kurt
I know how floats work...

thats why i said the precision should be higher.. not that it has to be
0.9f..
in fact if I print out 1f-0.05f-0.05f it is exactly 0.9f

while 1f-0.05f-0.05f-0.05f is 0.84999996 what is ok and in the range of
the expected precision.. but a twentyth mistake on calculations between
-1 and 1 should be much harder to achieve...
.