       • To: mathgroup at smc.vnet.net
• Subject: [mg126235] Re: Serious Bug in Mathematica 7 and 8.0.4.0 (latest version)
• From: Bill Rowe <readnews at sbcglobal.net>
• Date: Thu, 26 Apr 2012 05:29:57 -0400 (EDT)
• Delivered-to: l-mathgroup@mail-archive0.wolfram.com

```On 4/23/12 at 5:41 AM, amayer at alum.mit.edu (Alexander Mayer) wrote:

>In:= (* This notebook produced by Mathematica 8.0.4.0 *) (*
>Platform: OSX 10.6.8 on MacBook Pro *)

>In:= b = 6371.01 (* We set the value of b to this real number. *)

>Out= 6371.01

>In:= SetPrecision[a = b, 20] (* We test the actual value of b. *)

>Out= 6371.0100000000002183

This is not a bug in Mathematica nor is it unique to version
8.0.4. When you enter

6371.01

you are entering a machine precision number that has
approximately 16 digits of precision. Since this is a machine
precision number, the binary value stored is determined by the
FPU in your Mac, not Mathematica.

There are several ways to tell Mathematica you want the value
6371.01 to have a precision of 20 digits. The simplest way (in
my opinion) is to enter the value like

6371.0`20

An alternative method would be

N[637101/100, 20]

Either of these methods invokes Mathematica's arbitrary
precision arithmetic and the binary bits used to store the value
are determined by Mathematica rather than your specific hardware.

Additionally, if you are to use SetPrecision to increase the
precision of a machine precision number you simply cannot do it
using the syntax you tried. That is

In:= b = 6371.01;
SetPrecision[a = b, 20];

In:= Precision /@ {a, b}

Out= {MachinePrecision,MachinePrecision}

In:= RealDigits[a] === RealDigits[b]

Out= True

In:= a = SetPrecision[b, 20];

In:= Precision /@ {a, b}

Out= {20.,MachinePrecision}

In:= RealDigits[a] === RealDigits[b]

Out= False

That is SetPrecision does not change the precision of its
argument. Instead it returns a value with the requested
precision as determined by the argument given.

```

• Prev by Date: NonlinearModelFit and Complex Data
• Next by Date: Re: About linear programming