POV-Ray : Newsgroups : povray.beta-test : while bug ? Server Time
11 Oct 2026 19:20:27 EDT (-0400)
  while bug ? (Message 1 to 27 of 27)  
From: Mael
Subject: while bug ?
Date: 10 Oct 2001 04:12:39
Message: <3bc402f7$1@news.povray.org>
#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

From: ingo
Subject: Re: while bug ?
Date: 10 Oct 2001 05:18:40
Message: <Xns9136730FC78FDseed7@povray.org>
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

From: Ron Parker
Subject: Re: while bug ?
Date: 10 Oct 2001 08:00:15
Message: <slrn9s8e2f.9hj.ron.parker@fwi.com>
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

From: Mael
Subject: Re: while bug ?
Date: 10 Oct 2001 08:30:07
Message: <3bc43f4f@news.povray.org>
> 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

From: Francois Labreque
Subject: Re: while bug ?
Date: 10 Oct 2001 08:39:10
Message: <3BC4411A.7060206@videotron.ca>
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

From: Mael
Subject: Re: while bug ?
Date: 10 Oct 2001 08:46:21
Message: <3bc4431d$1@news.povray.org>
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

From: Ron Parker
Subject: Re: while bug ?
Date: 10 Oct 2001 08:54:04
Message: <slrn9s8h7d.9kj.ron.parker@fwi.com>
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

From: Anders K 
Subject: Re: while bug ?
Date: 10 Oct 2001 08:59:42
Message: <3bc4463e$1@news.povray.org>
> #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

From: Francois Labreque
Subject: Re: while bug ?
Date: 10 Oct 2001 09:03:49
Message: <3BC446E1.3090107@videotron.ca>
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

From: Warp
Subject: Re: while bug ?
Date: 10 Oct 2001 09:55:02
Message: <3bc45335@news.povray.org>
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

From: Slime
Subject: Re: while bug ?
Date: 10 Oct 2001 10:29:28
Message: <3bc45b48$1@news.povray.org>
Note that counting in integers will work fine, and so should counting by
fractions that are non-repeating decimals in binary, such as .25, .125, and
.0625.

- Slime
[ http://www.slimeland.com/ ]
[ http://www.slimeland.com/images/ ]

"Francois Labreque" <fla### [at] videotronca> wrote in message
news:3BC### [at] videotronca...
>
>
> 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

From: Warp
Subject: Re: while bug ?
Date: 10 Oct 2001 10:44:44
Message: <3bc45edc@news.povray.org>
Slime <noo### [at] hotmailcom> wrote:
: Note that counting in integers will work fine

... as long as they are not too big.

  Of course the integers you can handle accurately with a double type are
quite big (several thousands of millions...).


-- 
#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

From: Greg M  Johnson
Subject: Re: while bug ?
Date: 11 Oct 2001 10:22:44
Message: <3BC5AAE4.2D531AF1@aol.com>
Warp wrote:

> (several thousands of millions...).

Now *there's* a phrase to cause anxiety in an American listening to an
international audience.

thousand=1E03
million = 1E06

thousand millions=1E09?


Post a reply to this message

From: Trevor Quayle
Subject: Re: while bug ?
Date: 11 Oct 2001 10:40:03
Message: <3bc5af43$1@news.povray.org>
I had a discussion at work here about that once:

In the US:
million = 10^6
billion = 10^9  (thousand million)

In UK:
million = 10^6
billion = 10^12 (million million)


Read this article from the Straight Dope:
http://www.straightdope.com/mailbag/mgazilli.html

-tgq

"Greg M. Johnson" <"gregj56590[:-0]"@aol.com> wrote in message
news:3BC5AAE4.2D531AF1@aol.com...
> Warp wrote:
>
> > (several thousands of millions...).
>
> Now *there's* a phrase to cause anxiety in an American listening to an
> international audience.
>
> thousand=1E03
> million = 1E06
>
> thousand millions=1E09?
>


Post a reply to this message

From: Warp
Subject: Re: while bug ?
Date: 11 Oct 2001 11:37:36
Message: <3bc5bcbf@news.povray.org>
Greg M. Johnson <"gregj56590[:-0]"@aol.com> wrote:
:> (several thousands of millions...).

: Now *there's* a phrase to cause anxiety in an American listening to an
: international audience.

  I know the 'billion' problem in the UK/US, so I deliberately used the
term "thousands of millions" instead. I don't know how good it sounds, but
I don't care; I don't want to cause confusion.

-- 
#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

From: Greg M  Johnson
Subject: Re: while bug ?
Date: 11 Oct 2001 12:11:20
Message: <3BC5C457.3954809B@aol.com>
and "thousand" is 10^3.

Trevor Quayle wrote:

> I had a discussion at work here about that once:
>
> In the US:
> million = 10^6
> billion = 10^9  (thousand million)
>
> In UK:
> million = 10^6
> billion = 10^12 (million million)
>


Post a reply to this message

From: Greg M  Johnson
Subject: Re: while bug ?
Date: 11 Oct 2001 13:08:49
Message: <3BC5D1D0.24B313B8@aol.com>
Warp wrote:

> term "thousands of millions" instead. I don't know how good it sounds, but
> I don't care; I don't want to cause confusion.

Is that 10^9?


Post a reply to this message

From: Warp
Subject: Re: while bug ?
Date: 11 Oct 2001 19:17:03
Message: <3bc6286f@news.povray.org>
Greg M. Johnson <"gregj56590[:-0]"@aol.com> wrote:
:> term "thousands of millions" instead. I don't know how good it sounds, but
:> I don't care; I don't want to cause confusion.

: Is that 10^9?

  If you take a million one thousand times, how much do you get?-)

-- 
#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

From: Tom Melly
Subject: Re: while bug ?
Date: 12 Oct 2001 10:24:39
Message: <3bc6fd27@news.povray.org>
"Mael" <mae### [at] hotmailcom> wrote in message news:3bc43f4f@news.povray.org...
> isn t it strange to get a roundoff error for only 10 additions  ? i thought
> pov was more precise :(
>

On that subject, a recent faq wot I wrote (corrections and/or criticisms happily
accepted - and please note the very long url)

http://www.ccl.com/cgi-bin/protonfaq.cgi?faq=itemconfigwhydowetalkofaccuracynots
izeforfloatingpointnumbers


Post a reply to this message

From: Greg M  Johnson
Subject: Re: while bug ?
Date: 12 Oct 2001 14:00:46
Message: <3BC72F71.25A8D9A0@aol.com>
10^9, unless outside the territorial United States, ha mon?

Warp wrote:

>   If you take a million one thousand times, how much do you get?-)


Post a reply to this message

From: Warp
Subject: Re: while bug ?
Date: 12 Oct 2001 16:39:06
Message: <3bc754ea@news.povray.org>
Greg M. Johnson <"gregj56590[:-0]"@aol.com> wrote:
: 10^9, unless outside the territorial United States, ha mon?

  Where "a thousand millions" is not 10^9?

-- 
#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

From: Greg M  Johnson
Subject: Re: while bug ?
Date: 15 Oct 2001 08:57:07
Message: <3BCADCE4.889DD713@aol.com>
Warp wrote:

> Greg M. Johnson <"gregj56590[:-0]"@aol.com> wrote:
> : 10^9, unless outside the territorial United States, ha mon?
>
>   Where "a thousand millions" is not 10^9?

The vagueness of your reply in my attempt to nail down its meaning merely
underscores the barrier to technical communication in international audiences
from the use of either the terms "thousand" or "million".  Americans won't
know what a non-American really means; I'm afraid I'll never know what you
mean...


Post a reply to this message

From: Anders K 
Subject: Re: while bug ?
Date: 15 Oct 2001 09:51:27
Message: <3bcae9df$1@news.povray.org>
> The vagueness of your reply in my attempt to nail down its meaning merely
> underscores the barrier to technical communication in international
audiences
> from the use of either the terms "thousand" or "million".  Americans won't
> know what a non-American really means; I'm afraid I'll never know what you
> mean...

FYI, my dictionary gives two definitions of "billion" (the American 10^9 and
the British 10^12) but only one definition for "million" (10^6) and one
definition for "thousand" (10^3). So IMHO there can be no ambiguity in
saying thousand million.


Post a reply to this message

From: Trevor Quayle
Subject: Re: while bug ?
Date: 15 Oct 2001 10:15:02
Message: <3bcaef66$1@news.povray.org>
This is correct.  10^n is 10^n no matter where you are, it is a (as far as
we know) universal constant.  The problem comes with terminology.  A
"thousand" is the same in US/UK (10^3), so is a "million" (10^6) and,
therefore, so would a "thousand million"  (10^3 x 10^6 = 10^9), but in the
US a "thousand million" is also known as a "billion" but not so in the UK,
it is still a "thousand million" (Or also a "milliard").  The UK reserve the
word "billion" to describe a "million million" (which is known as "trillion"
in the US).  Also, a UK "trillion" is a "million million  million" (quite
the mouthful) or 10^18 ("million"^3, "quadrillion" = "million"^4, etc.). All
in all, it is always better to use scientific notation so as to keep
confusion about such large numbers to a minimum when talking to an
international audience.

-tgq

"Anders K." <and### [at] f2scom> wrote in message
news:3bcae9df$1@news.povray.org...
> > The vagueness of your reply in my attempt to nail down its meaning
merely
> > underscores the barrier to technical communication in international
> audiences
> > from the use of either the terms "thousand" or "million".  Americans
won't
> > know what a non-American really means; I'm afraid I'll never know what
you
> > mean...
>
> FYI, my dictionary gives two definitions of "billion" (the American 10^9
and
> the British 10^12) but only one definition for "million" (10^6) and one
> definition for "thousand" (10^3). So IMHO there can be no ambiguity in
> saying thousand million.
>
>
>


Post a reply to this message

From: Anders K 
Subject: Re: while bug ?
Date: 15 Oct 2001 10:41:10
Message: <3bcaf586$1@news.povray.org>
> This is correct.  10^n is 10^n no matter where you are, it is a (as far as
> we know) universal constant.  The problem comes with terminology. [...]

What Warp said was "several thousands of millions". While Americans may have
another name for it, one thousand million is still 10^9. There is no other
way it can be interpreted.


Post a reply to this message

From: Trevor Quayle
Subject: Re: while bug ?
Date: 15 Oct 2001 11:59:57
Message: <3bcb07fd@news.povray.org>
Yes, that's right, but I think Greg's original point was that Americans tend
not to use the phrase "thousands of millions" but rather "billions" and
maybe wonder why Warp specified thousands of millions rather than just
saying billions even though they mean the same in American terms.


-tgq


"Anders K." <and### [at] f2scom> wrote in message
news:3bcaf586$1@news.povray.org...
> > This is correct.  10^n is 10^n no matter where you are, it is a (as far
as
> > we know) universal constant.  The problem comes with terminology. [...]
>
> What Warp said was "several thousands of millions". While Americans may
have
> another name for it, one thousand million is still 10^9. There is no other
> way it can be interpreted.
>
>
>
>


Post a reply to this message

From: Michael Andrews
Subject: Re: while bug ?
Date: 17 Oct 2001 07:46:08
Message: <3BCD7071.71DF9F86@reading.ac.uk>
Trevor Quayle wrote:
> 
> This is correct.  10^n is 10^n no matter where you are, it is a (as far as
> we know) universal constant.  

Well, this is true as long as everyone is working in the same base. 

10^n (base 13) is not the same as 10^n (base 10), so 10^n may not be the
same everywhere. ;-)

	Mike Andrews.


Post a reply to this message

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