|
|
> The result, however, lists seven iterations:
>
> i = 0.000000
> i = 0.166667
> i = 0.333333
> i = 0.500000
> i = 0.666667
> i = 0.833333
> i = 1.000000
>
> There should only be six!
I wouldn't mind betting that 1/6 cannot be exactly represented by a floating
point number. So by the time you have summed 6 of them you actually have
0.9999999999999999999999 stored and not 1.0000000000000000 as you expect.
The output only shows 1.00000 because it is rounded.
You shouldn't rely on floating point numbers being exact like you are doing,
find another way to do it.
This goes for any programming language using the normal floating point data
types by the way, not just POV.
Post a reply to this message
|
|