Re: numeric issue: 0.95 - 0.05 == 0.8499996
- From: Christian <fakemail@xxxxxx>
- Date: Thu, 10 May 2007 12:21:46 +0200
~kurt schrieb:
Christian <fakemail@xxxxxx> wrote:I know how floats work...
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
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...
.
- Follow-Ups:
- Re: numeric issue: 0.95 - 0.05 == 0.8499996
- From: ~kurt
- Re: numeric issue: 0.95 - 0.05 == 0.8499996
- References:
- numeric issue: 0.95 - 0.05 == 0.8499996
- From: Maciej
- Re: numeric issue: 0.95 - 0.05 == 0.8499996
- From: Philipp Taprogge
- Re: numeric issue: 0.95 - 0.05 == 0.8499996
- From: Christian
- Re: numeric issue: 0.95 - 0.05 == 0.8499996
- From: ~kurt
- numeric issue: 0.95 - 0.05 == 0.8499996
- Prev by Date: Re: How can I retrieve the number of cores?
- Next by Date: Re: How can I retrieve the number of cores?
- Previous by thread: Re: numeric issue: 0.95 - 0.05 == 0.8499996
- Next by thread: Re: numeric issue: 0.95 - 0.05 == 0.8499996
- Index(es):