       Re: with machine-precision input

• To: mathgroup at smc.vnet.net
• Subject: [mg128403] Re: with machine-precision input
• From: Bill Rowe <readnews at sbcglobal.net>
• Date: Tue, 16 Oct 2012 03:22:56 -0400 (EDT)
• Delivered-to: l-mathgroup@mail-archive0.wolfram.com
• Delivered-to: l-mathgroup@wolfram.com
• Delivered-to: mathgroup-newout@smc.vnet.net
• Delivered-to: mathgroup-newsend@smc.vnet.net

```On 10/14/12 at 11:40 PM, fateman at cs.berkeley.edu (Richard Fateman)
wrote:

>try this on Mathematica 8:

>q = 429515858585961022071539/6922263581864661506963;

>Note that q was chosen so that
>Rationalize[N[q,45],0] == q.

Not here:

In:= q = 429515858585961022071539/6922263581864661506963;
Rationalize[N[q, 45], 0] == q

Out= False

but

In:= Rationalize[N[q, 45]] == q

Out= True

>Peculiarly, then SetPrecision[N[q,45],100]-N[q,100] is not zero but

Why would you expect this to be zero? Per the documentation:

SetPrecision will first expose any hidden extra digits in the
internal binary representation of a number, and, only after
these are exhausted, add trailing zeros.

So unless q can be exactly expressed with 45 digits there will
be a non-zero difference. Here:

In:= SetPrecision[N[q, 45], 100] - N[q, 100]

Out= 3.3475286706596422492*10^-78

but note:

In:= SetPrecision[N[q, 45], 100] - N[q, 45]

Out= 0.*10^-44

as it should.

And here is:

In:= \$Version

Out= 8.0 for Mac OS X x86 (64-bit) (October 5, 2011)

```

• Prev by Date: Re: how to put variables
• Next by Date: Re: Resources on using stylesheets for publishing
• Previous by thread: Re: Infinite expression, NDSolve
• Next by thread: Plot in function