Re: bug in IntegerPart ?

• To: mathgroup at smc.vnet.net
• Subject: [mg47871] Re: bug in IntegerPart ?
• From: "Peltio" <peltio at twilight.zone>
• Date: Thu, 29 Apr 2004 03:05:44 -0400 (EDT)
• References: <c6l8dj\$isr\$1@smc.vnet.net> <c6o54u\$cns\$1@smc.vnet.net>
• Reply-to: "Peltio" <peltioNOSP at Mdespammed.com.invalid>
• Sender: owner-wri-mathgroup at wolfram.com

```"AC" wrote:

this one will be luckier : ) )

>The decimal numbers (1.65 - 1.3) and .35 are identical. The way
>Mathematica performs subtraction makes them different.

I think this is a correct statement, but is a little bit too specific.
I'd rather say: the way _digital computers_ perform subtractions makes them
different. The subtraction of machine precision numbers is done with machine
arithmetics, and that requires the terms to be translated into binary.

We can experience the same loss of precision with decimal arithmetic, by
We know that
1/6+2/3=5/6
Now suppose we have a 'decimal computer' with a machine precision of three
digits. Additions and subtractions have to be carried out in this machine
precision. What do we get?
1/6 becomes 0.167
2/3 becomes 0.667
theis sum, accordind to our Decimal ALU (that operates only on the truncated
decimal expansions of our rational numbers). is:
0.167+0.667 = 0.834
Which is different from the decimal representation of the correct result
5/6 is 0.833

Hence, in machine precision, 1/6+2/3 is different from 5/6, depsite the fact
that every children know they are the same.
This is the world of machine precision arithmetic.
It's a harsh world : ]

cheers,
Peltio

PS
In my previous (lost) post I pointed out that in this world things are
different according to the order of the computation. Evaluate the following
to see what I mean:
(1.65/0.007 - 1.3/0.007) - 0.35/0.007
(1.65 - 1.3)/0.007 - 0.35/0.007
(1.65 - 1.3 - 0.35)/0.007
(1.65 - (1.3 + 0.35))/0.007
Repeat the same calculations in a C program with double precision and see
what you get.

```

• Prev by Date: RE: Re: Matrix Expansion question to Mathgroup
• Next by Date: Re: FindRoot cannot find obvious solution
• Previous by thread: Re: bug in IntegerPart ?
• Next by thread: Re: bug in IntegerPart ?