POV-Ray : Newsgroups : povray.general : Blender Vs PovRay : Re: Blender Vs PovRay Server Time
31 Oct 2024 21:26:49 EDT (-0400)
  Re: Blender Vs PovRay  
From: stbenge
Date: 25 Oct 2008 00:13:41
Message: <49029cf5@news.povray.org>
Nicolas Alvarez wrote:
> Nicolas Alvarez wrote:
>> The problem with doing #declare V=V+1/100; is that it might not reach
>> 1.0000 exactly at the end of the loop (because of floating point
>> inaccuracies), so it might run one time too many.
> 
> Or even if it runs runs the correct number of times, it may have slightly
> off values. And errors would *accumulate*.
>
> Tested in Python:
>>>> x = 0;
>>>> for i in range(0,100):
> ...     x += 1.0/100;
> ... 
>>>> print x;
> 1.0000000000000007

I see what you mean. I've never encountered any unwanted effects from 
using fractional number-dependent loops, but it's a good thing to keep 
in mind. Errors at the 16th decimal place are acceptable for most of the 
things I do, but there will probably come a time when your input saves 
me from beating my head against a hard surface :)

Sam


Post a reply to this message

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