POV-Ray : Newsgroups : povray.general : Problems with iterations : Re: Problems with iterations Server Time
31 Jul 2024 02:26:11 EDT (-0400)
  Re: Problems with iterations  
From: scott
Date: 10 Jan 2008 04:04:44
Message: <4785dfac$1@news.povray.org>
> 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

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.