Re: Mod bug
- To: mathgroup at smc.vnet.net
- Subject: [mg42851] Re: [mg42814] Mod bug
- From: Selwyn Hollis <selwynh at earthlink.net>
- Date: Wed, 30 Jul 2003 19:31:00 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
It looks as though this is related to the fact that 0.1 can't be represented exactly in binary. Try the same with .125 and you'll see it works as expected. Also, Quotient runs into the same problem. For example, Quotient[8,.1] and Quotient[8.1,.1] both return 80. Clearly Mod was not designed for floating-point inputs. You'll have better luck defining your own, something like: flMod[x_,y_]:= y*FractionalPart[x/y] ----- Selwyn Hollis http://www.math.armstrong.edu/faculty/hollis On Wednesday, July 30, 2003, at 04:07 AM, frauendorfer wrote: > A program written in version 3 using Mod fails completely in version > 4.2 > and 5. > Checking Mod I found a quite erratic behavior.For example Mod[.5,.1] > gives > the result 0.1. > A list increasing from 0.1 to 10 in 100 steps of 0.1, run through > Mod[*,.1] > gives 47 wrong answers. > > E. Frauendorfer > > >