MathGroup Archive 2006

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

Search the Archive

Re: SetPrecision causes logical comparisons to fail in Mathematica 5.1 on Mac OS X?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg63982] Re: [mg63967] SetPrecision causes logical comparisons to fail in Mathematica 5.1 on Mac OS X?
  • From: Pratik Desai <pdesai1 at umbc.edu>
  • Date: Thu, 26 Jan 2006 03:43:05 -0500 (EST)
  • References: <200601251345.IAA25867@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

jjdmon wrote:

>I am running Mathematica 5.1.1.0 on Mac OS 10.3.9 and have encountered
>what seems like a bug using SetPrecision to limit the significant
>places of real numbers.
>
>If I do this:
>
>In: x=SetPrecision[1.101,2]
>Out: 1.1
>
>I get this:
>
>In: x==0.0
>Out: True
>
>In: x==1.0
>Out: True
>
>Is this expected behavior?
>
>  
>
For some reason, Mathematica does not want you to set presion to 2. 
Because it clashes with its default value for MinPrecision and 
MaxPrecision. I guess the tacit idea being that nobody wants to do 
calculations with 2 digit precision. Here is an example from the 
documentation which bypases the Max and Min precision settings or rather 
augments it. It is available in the help for
$MinPrecision


In[321]:=
Clear[x]
SetAttributes[FixedPrecisionEvaluate,HoldFirst]
FixedPrecisionEvaluate[x_,p_?NumberQ]:=Block[{$MinPrecision=p,$MaxPrecision=p},x];
x:=FixedPrecisionEvaluate[1.101,2]
x==1.0
x==0.0


Out[325]=
False

Out[326]=
False


  • Prev by Date: Re: Mathematica 5.2 multithreading using Debian
  • Next by Date: Re: SetPrecision causes logical comparisons to fail in Mathematica 5.1 on Mac OS X?
  • Previous by thread: SetPrecision causes logical comparisons to fail in Mathematica 5.1 on Mac OS X?
  • Next by thread: Re: Re: SetPrecision causes logical comparisons to fail in Mathematica 5.1 on Mac OS X?