POV-Ray : Newsgroups : povray.general : Problems with iterations : Re: Problems with iterations Server Time
31 Jul 2024 08:32:22 EDT (-0400)
  Re: Problems with iterations  
From: Tim Attwood
Date: 10 Jan 2008 19:48:28
Message: <4786bcdc$1@news.povray.org>
> I'm wondering if simply changing the condition to "i < 0.999999" is 
> sufficient.
> The likelihood of the variable falling outside this range is pretty slim. 
> Also,
> to how many decimal places does POV-Ray calculate? I thought the "system
> specific" option in the "str" function returned values using this amount.

1/6 is a repeating decimal and binary
0.1(6) decimal, 0.00(10) binary.
In FP this is represented by a significand and an exponent
that moves the decimal place, in binary. The significand for 1/6 is
then stored as 1.(01) in binary, except that repeating decimals
are not dealt with in IEEE 754! They just store 23 bits worth and stop,
so while the actual number should be 1.(01) binary, it's really
using 1.01010101010101010101010 in IEEE 754.

In other words it depends on the size of your increment...
1 in decimal is
1 in binary and
1.00000000000000000000000 in IEEE 754,
so there is no FP error.

0.1 in decimal is
0.000(1100) in binary and
1.10011001100110011001100 in IEEE 754
so it has some FP error.

Decimal numbers that convert to terminating binary
numbers have denominators that are powers of 2.
So for example 3/8 is
0.375 in decimal,
0.011 in binary, and
1.10000000000000000000000 in IEEE 754
so there is no FP error issues with these
numbers either.


Post a reply to this message

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