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

Home » Public Forums » archive » Re: Simple MODULO question.
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: Simple MODULO question. [message #6454] Wed, 03 July 1996 00:00 Go to previous message
peter is currently offline  peter
Messages: 80
Registered: February 1994
Member
S. Penzes (penzes@dres.dnd.ca) wrote:
: It truly is a simple question and the online help doesn't seem to
: answer it. So it's either a bug or I have a short cicuit in a synapse
: someplace. Anyway here it is:

: Why does print,1.0 mod 0.25 return 0.00000 (as expected)
: generally 1.0 mod (1.0/2^n) returns 0
: while print,1.0 mod 0.2
: or print,1.0 mod (1.0/5.0) return 0.200000
: generally 1.0 mod (1.0 / n)

Probably because, in floating point, 0.25 is represented exactly, so
that 1.0/0.25 = 0.0, while 0.2 is not represented exactly. I'll guess
that 0.2 is actually something like 0.200000001, so that 5*0.2 is
greater than 1.0, while 1.0-4*0.2 is 0.199999996, which prints at 0.2.

Relying on true equality of floating point numbers as a test (which this
is doing, relying on 5.0*0.2=1.0) is, well, unreliable.

Peter

--------------------------------
Peter Webb, HP Labs Medical Dept
E-Mail: peter_webb@hpl.hp.com
Phone: (415) 813-3756
[Message index]
 
Read Message
Read Message
Previous Topic: Image transformation retaining pixelation
Next Topic: Re: Reading in a bunch of bytes

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

Current Time: Wed Oct 08 15:23:06 PDT 2025

Total time taken to generate the page: 0.00418 seconds