comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » strange problem: Alarm Clock????....
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Strange problem [message #28140 is a reply to message #2626] Sun, 25 November 2001 17:38 Go to previous message
Bhautik Joshi is currently offline  Bhautik Joshi
Messages: 21
Registered: November 2001
Junior Member
> Anybody know what's going on?

My spin on it:

Well, I think it may be a problem that goes right down to the core, and
is not just restricted to FOR loops.

Example:

MOO>a=replicate(0.1,100)
MOO>print, total(a)
10.0000
MOO>print, total(a) - 0.1*100
1.90735e-06

argh! where I think the problem may lie is with the binary
representation of floating point numbers. Now, its been a
loooooooooooooooooooooooong while since I did computer architecture
(yes, it is a real subject at uni) but as far as I remember, in floating
point binary, there is no 'exact' representation for 0.1.

However, lets take 0.5 - which is a quarter of 2; something nice and
(pardon the expression) base-twoish.

MOO>a=replicate(0.5,100)
MOO>print, total(a) - 0.5*100
0.00000

Lets change the game slightly again:

MOO>a=replicate(0.51,100)
MOO>print, total(a) - 0.51*100
-4.95911e-05

should i be worried?


--
/--------------------------------------------------(__)----- ----\
| nbj@imag.wsahs.nsw.gov.au | phone: 0404032617 |..|--\ -moo |
| ICQ #: 2464537 | http://cow.mooh.org | |--| |
\--------------------------------------------------\OO/|| ------/
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Obfuscated IDL
Next Topic: Array index for arrays

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 15:26:33 PDT 2025

Total time taken to generate the page: 0.00351 seconds