|
|
|
|
|
|
| |
| |
|
|
|
|
| |
| |
|
|
#local i=0;
#while (i<1)
#debug concat(str(i,0,2),"\n")
#local i=i+0.1;
#end
gives
0.00
0.10
0.20
0.30
0.40
0.50
0.60
0.70
0.80
0.90
1.00
is the1.00 normal ???
if we change i=i+0.1 into i=i+0.2 it stops at 0.8
povray3.5b6 win2000 Athlon 900MHz 256MB
M
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
in news:3bc402f7$1@news.povray.org Mael wrote:
> is the1.00 normal ???
> if we change i=i+0.1 into i=i+0.2 it stops at 0.8
>
Same happens in 3.1g
Ingo
--
Photography: http://members.home.nl/ingoogni/
Pov-Ray : http://members.home.nl/seed7/
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
On 10 Oct 2001 05:18:40 -0400, ingo wrote:
>in news:3bc402f7$1@news.povray.org Mael wrote:
>
>> is the1.00 normal ???
>> if we change i=i+0.1 into i=i+0.2 it stops at 0.8
>>
>
>Same happens in 3.1g
It's roundoff error. I is probably .9999999 or so for the last iteration,
but it gets rounded for output.
--
#macro R(L P)sphere{L F}cylinder{L P F}#end#macro P(V)merge{R(z+a z)R(-z a-z)R(a
-z-z-z a+z)torus{1F clipped_by{plane{a 0}}}translate V}#end#macro Z(a F T)merge{
P(z+a)P(z-a)R(-z-z-x a)pigment{rgbt 1}hollow interior{media{emission T}}finish{
reflection.1}}#end Z(-x-x.2y)Z(-x-x.4x)camera{location z*-10rotate x*90}
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
> It's roundoff error. I is probably .9999999 or so for the last iteration,
> but it gets rounded for output.
isn t it strange to get a roundoff error for only 10 additions ? i thought
pov was more precise :(
M
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Mael wrote:
>>It's roundoff error. I is probably .9999999 or so for the last iteration,
>>but it gets rounded for output.
>>
>
> isn t it strange to get a roundoff error for only 10 additions ? i thought
> pov was more precise :(
>
> M
>
You can get roundoff error with only one addition. It comes from the
fact that floating point numbers can not always be converted between
base2 and base10 without roundoff.
To see what happens, you have to modify your code to show all the
decimal places, like this:
#local i=0;
#while (i<1)
#debug concat(str(i,0,17),"\n")
#local i=i+0.1;
#end
Which (on my machine) produces:
0.00000000000000000
0.10000000000000001
0.20000000000000001
0.30000000000000004
0.40000000000000002
0.50000000000000000
0.59999999999999998
0.69999999999999996
0.79999999999999993
0.89999999999999991
0.99999999999999989
--
/*Francois Labreque*/#local a=x+y;#local b=x+a;#local c=a+b;#macro P(F//
/* flabreque */L)polygon{5,F,F+z,L+z,L,F pigment{rgb 9}}#end union
/* @ */{P(0,a)P(a,b)P(b,c)P(2*a,2*b)P(2*b,b+c)P(b+c,<2,3>)
/* videotron.ca */}camera{location<6,1.25,-6>look_at a orthographic}
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
ok, thank you, it's clear.. we can't trust computers for maths :)
i'll change the test in the loop to avoid this
M
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
On Wed, 10 Oct 2001 14:50:11 +0200, Mael wrote:
>ok, thank you, it's clear.. we can't trust computers for maths :)
The problem is that .1 in decimal is a repeating fraction in binary, so it
can never be represented precisely, just as 1/3 is a repeating fraction in
decimal (but terminates in base 3.)
--
#macro R(L P)sphere{L F}cylinder{L P F}#end#macro P(V)merge{R(z+a z)R(-z a-z)R(a
-z-z-z a+z)torus{1F clipped_by{plane{a 0}}}translate V}#end#macro Z(a F T)merge{
P(z+a)P(z-a)R(-z-z-x a)pigment{rgbt 1}hollow interior{media{emission T}}finish{
reflection.1}}#end Z(-x-x.2y)Z(-x-x.4x)camera{location z*-10rotate x*90}
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
> #local i=0;
> #while (i<1)
> #debug concat(str(i,0,2),"\n")
> #local i=i+0.1;
> #end
Try
#local i = 0;
#while (i < 10)
#debug concat(str(i/10, 0, 2), "\n")
#local i = i + 1;
#end
Since there is no round off error with adding integers.
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Mael wrote:
> ok, thank you, it's clear.. we can't trust computers for maths :)
Yes we can. As long as we remembers that computers do not have the same
number of fingers to count on.
--
/*Francois Labreque*/#local a=x+y;#local b=x+a;#local c=a+b;#macro P(F//
/* flabreque */L)polygon{5,F,F+z,L+z,L,F pigment{rgb 9}}#end union
/* @ */{P(0,a)P(a,b)P(b,c)P(2*a,2*b)P(2*b,b+c)P(b+c,<2,3>)
/* videotron.ca */}camera{location<6,1.25,-6>look_at a orthographic}
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Mael <mae### [at] hotmailcom> wrote:
: isn t it strange to get a roundoff error for only 10 additions ? i thought
: pov was more precise :(
0.1 can't be represented accurately with binary floating point format.
The reason is the same as why 1/3 can't be represented accurately with
decimal format.
--
#macro N(D,I)#if(I<6)cylinder{M()#local D[I]=div(D[I],104);M().5,2pigment{
rgb M()}}N(D,(D[I]>99?I:I+1))#end#end#macro M()<mod(D[I],13)-6,mod(div(D[I
],13),8)-3,10>#end blob{N(array[6]{11117333955,
7382340,3358,3900569407,970,4254934330},0)}// - Warp -
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |