POV-Ray : Newsgroups : povray.general : Bug in processing #while loop for low comparison values? : Bug in processing #while loop for low comparison values? Server Time
1 Aug 2024 20:07:59 EDT (-0400)
  Bug in processing #while loop for low comparison values?  
From: hobbes
Date: 12 Apr 2005 18:26:07
Message: <64io51tbvdhf1jpee5h2f7ed9lomqd8gf0@4ax.com>
Hi all,

POV-Ray for Windows version 3.6.1a.icl8.win32 
Windows XP sp2

I believe I have discovered a bug with #while loop processing when
comparing conditional values that are less than one.  When checking
the "Loop" variable for less than one, the #while block is still
processed when the value one is reached.

The bug can be best explained and reproduced with the following code.

>>> snip >>>

// demonstration of possible bug in POV-Ray for Windows
// Version 3.6.1a.icl8.win32
camera {
  location <0, 0.5, -2>
  look_at <0, 0.5, 0>
}


// bug - should not enter while block when "Loop" = 1
#declare Loop = 0.0;
#while ( Loop < 1 )
  sphere {
    <-0.1, Loop, 0>, 0.05 
    pigment { rgb <1, 0, 0> } 
    finish { ambient 1 } 
  }
  #declare Loop = Loop + 0.1;
#end

// example for comparison  
#declare Loop = 0.0;
#while ( Loop < 0.99 )
  sphere {
    <0.1, Loop, 0>, 0.05 
    pigment { rgb <0, 1, 0> } 
    finish { ambient 1 } 
  }
  #declare Loop = Loop + 0.1;
#end

>>> snip >>>

The #while loop that produces the red spheres is executed for the
"Loop" value of one when it should stop at 0.90, similar to "Loop <=
1".  The #while loop that produces the green spheres is there for
comparison.

The #while loop processes properly if the comparison is changed to a
higher value, such as "Loop < 10".  It also fails for lower values,
such as "Loop < 0.90", so the problem seems to be for values of one or
less.

Unless I'm really missing something obvious, this seems to be a bug.

Thanks to everyone involved for such a great product!

Best Regards,

Kyle Johnson


Post a reply to this message

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