Re: Mod bug
- To: mathgroup at smc.vnet.net
- Subject: [mg42838] Re: Mod bug
- From: bobhanlon at aol.com (Bob Hanlon)
- Date: Wed, 30 Jul 2003 19:30:32 -0400 (EDT)
- References: <bg7vh3$hhp$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
You are using inexact numbers and will get inexact results due to machine
precision when storing numbers
Mod[.5,.1]
0.1
For exact results use exact numbers
Mod[1/2,1/10]
0
or
Mod[Rationalize[.5],Rationalize[.1]]
0
Union[Table[Mod[x,1/10],{x,1/10,10,1/10}]]
{0}
Bob Hanlon
In article <bg7vh3$hhp$1 at smc.vnet.net>, "frauendorfer"
<frauendorfer at perseus.fho-emden.de> 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.
>><BR><BR>