       • To: mathgroup at smc.vnet.net
• Subject: [mg126189] Re: Serious Bug in Mathematica 7 and 8.0.4.0 (latest version)
• From: Ingolf Dahl <ingolf.dahl at telia.com>
• Date: Tue, 24 Apr 2012 05:32:12 -0400 (EDT)
• Delivered-to: l-mathgroup@mail-archive0.wolfram.com
• References: <201204230941.FAA16597@smc.vnet.net>

```I think you are asking Mathematica for something that it never has promised
to deliver. In the documentation for SetPrecision we can read:
" When SetPrecision is used to increase the precision of a number, the
number is padded with zeros. The zeros are taken to be in base 2. In base
10, the additional digits are usually not zeros."

Define a new function to give what you want to obtain:

MySetPrecision[x_, prec_] := SetPrecision[Rationalize[x], prec]

Then

MySetPrecision[6371.01, 20]
6371.0100000000000000

Best regards

Ingolf Dahl
Sweden

> -----Original Message-----
> From: Alexander Mayer [mailto:amayer at alum.mit.edu]
> Sent: den 23 april 2012 11:42
> To: mathgroup at smc.vnet.net
> Subject: Serious Bug in Mathematica 7 and 8.0.4.0 (latest
version)
>
> 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
>
> In:= (* Mathematica has added a small constant! *)
>
> In:= (* Adding zeros to the 16th place fixes the problem. *)
>
> In:= c = 6371.0100000000000000
>
> Out= 6371.0100000000000000
>
> In:= SetPrecision[a = c, 20]
>
> Out= 6371.0100000000000000

```

• Prev by Date: Re: Controlling scale of Graphics on paper
• Next by Date: Re: Serious Bug in Mathematica 7 and 8.0.4.0 (latest version)