POV-Ray : Newsgroups : povray.general : another bug report Server Time
13 Aug 2024 17:25:51 EDT (-0400)
  another bug report (Message 1 to 3 of 3)  
From: Guy Rauscher
Subject: another bug report
Date: 6 Jul 1998 11:55:04
Message: <35A17F36.5507@netvision.net.il>
Hi!

This bug exsited in the 3.0 version as well but I just found out about
it now. In certain cases (maybe its related to the use of numbers with a
decimal point) a while loop such as this: #while(I<1) loops one time too
many (as if it was #while(I<=1)). Just run the attached script.

Guy


Post a reply to this message


Attachments:
Download 'us-ascii' (1 KB)

From: Andrew Hedges
Subject: Re: another bug report
Date: 6 Jul 1998 14:56:12
Message: <35A10FB9.99DDF7FC@open.ac.uk>
This looks like a "feature" of many programming languages that use
floating point numbers, including POVRay's. It's caused by inaccuracies
in the floating point calculations, such that tests like "T = 1.0" or "T
< 1.0" produce weird results. Try using a test such "abs(T - 1.0) <
0.01" where 0.01 is a sufficiently small number for the accuracy you
require, and things should work okay.

Andrew
-- 
Ob disclaimer: Of course, I might be wrong...

Guy Rauscher wrote:
> 
> Hi!
> 
> This bug exsited in the 3.0 version as well but I just found out about
> it now. In certain cases (maybe its related to the use of numbers with a
> decimal point) a while loop such as this: #while(I<1) loops one time too
> many (as if it was #while(I<=1)). Just run the attached script.
> 
> Guy
> 
>   ------------------------------------------------------------------------

[most of example snipped]

> // Doesn't work!
> #declare T = 0;
> #declare Tinterval = 0.1;
> #while(T < 1)
>    #declare T = T + Tinterval;
>    #debug concat("T",str(T,1,1)," ")
> #end


Post a reply to this message

From: PoD
Subject: Re: another bug report
Date: 6 Jul 1998 16:55:20
Message: <35A12B9E.1FA3@merlin.net.au>
Andrew Hedges wrote:
> 
> This looks like a "feature" of many programming languages that use
> floating point numbers, including POVRay's. It's caused by inaccuracies
> in the floating point calculations, such that tests like "T = 1.0" or "T
> < 1.0" produce weird results. Try using a test such "abs(T - 1.0) <
> 0.01" where 0.01 is a sufficiently small number for the accuracy you
> require, and things should work okay.
> 
> Andrew
> --
> Ob disclaimer: Of course, I might be wrong...
> 
> Guy Rauscher wrote:
> >
> > Hi!
> >
> > This bug exsited in the 3.0 version as well but I just found out about
> > it now. In certain cases (maybe its related to the use of numbers with a
> > decimal point) a while loop such as this: #while(I<1) loops one time too
> > many (as if it was #while(I<=1)). Just run the attached script.
> >
> > Guy
> >
> >   ------------------------------------------------------------------------
> 
> [most of example snipped]
> 
> > // Doesn't work!
> > #declare T = 0;
> > #declare Tinterval = 0.1;
> > #while(T < 1)
> >    #declare T = T + Tinterval;
> >    #debug concat("T",str(T,1,1)," ")
> > #end

Odd, POVRay is supposed to do that already.
According to the docs "A value of 0.0 is false and any non-zero value is
true. Note that extremely small values of about 1e-10 are considered
zero in case of round off errors."


Post a reply to this message

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