MathGroup Archive 2011

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Min-MaxPrecision?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg115768] Re: Min-MaxPrecision?
  • From: DrMajorBob <btreat1 at austin.rr.com>
  • Date: Thu, 20 Jan 2011 06:30:03 -0500 (EST)

Block had nothing to do with it.

In the block you subtracted 0.00000000000000000000000000000001`32, but in  
the other code you subtracted 0.0000000000000000000000000000001.

Switching them about gives

$MinPrecision = $MaxPrecision = 32;
var = 1 - 0.00000000000000000000000000000001`32;
N[var, 32] // RealDigits

{{9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
    9, 9, 9, 9, 9, 9, 9, 9, 9}, 0}

Block[{$MinPrecision = 32, $MaxPrecision = 32},
   1 - 0.0000000000000000000000000000001] // RealDigits

{{1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, 1}

The two subtracted objects are not identical:

0.0000000000000000000000000000001 === 0.00000000000000000000000000000001`32

False

and their precisions are different:

Precision /@ {0.0000000000000000000000000000001,
   0.00000000000000000000000000000001`32}

{MachinePrecision, 32.}

Bobby

On Wed, 19 Jan 2011 04:25:57 -0600, Marco Masi <marco.masi at ymail.com>  
wrote:

> I would like to run a program that makes always quad precison  
> calculations in all variables. I thought Mathematica would do that  
> internally by setting $MinPrecision = $MaxPrecision = nrd, with nrd the  
> number of digits. However, if I try
>
> $MinPrecision = $MaxPrecision = 32;
> var = 1 - 0.0000000000000000000000000000001;
> N[var, 32]
>
> I get 1. Whereas I expected 0.9999999999999999999999999999999
>
> Block seems to do the job. In fact
>
> Block[{$MinPrecision = 32, $MaxPrecision = 32},
>  1 - 0.00000000000000000000000000000001`32]
>
> gives 0.99999999999999999999999999999999.
>
> But that's not very useful in my case because I would like to run a long  
> program and can't apply it on all variables. Ideally I need something  
> like
>
> Block[{$MinPrecision = 32, $MaxPrecision = 32},
> ....... var in long program with zillions of calculations.....]
>
> And after execution know what exactly var is to 32 digits precision and  
> Exporting it to file with that precision. If I type var, or N[var,32] it  
> will output only with the default 15 digits. Export will consequently do  
> the same.
>
> Can anyone help?
>
> Marco.
>


-- 
DrMajorBob at yahoo.com


  • Prev by Date: Re: Mathematica 8 browser plugin and Firefox 3/4
  • Next by Date: Re: SetOptions does not work with Grid
  • Previous by thread: Min-MaxPrecision?
  • Next by thread: Mathematica 8 browser plugin and Firefox 3/4