Re: On default numerical precision
- To: mathgroup at smc.vnet.net
- Subject: [mg90740] Re: On default numerical precision
- From: sergio_r at mail.com
- Date: Tue, 22 Jul 2008 03:57:34 -0400 (EDT)
- References: <g5pj07$qbc$1@smc.vnet.net> <g5s9q0$51h$1@smc.vnet.net>
>From a mathematica help page: http://reference.wolfram.com/mathematica/ref/$Pre.html http://reference.wolfram.com/mathematica/ref/$Post.html $Pre is a global variable whose value, if set, is applied to every input expression. $Post is a global variable whose value, if set, is applied to every output expression. Does this mean that one needs to set both variables to maintain precision throughout a computational sesion? $Pre = ( #1 /. a_Real :> SetPrecision[a, 32]) &; $Post = ( #1 /. a_Real :> SetPrecision[a, 32]) &; Regards, Sergio PS. I am trying this stuff on a computer having In[1]:= $Version Out[1]= 5.0 for Linux (June 9, 2003) On Jul 20, 6:58 am, sergi... at mail.com wrote: > Jens thanks for you reply. I am not sure what > I am missing but here are the results of following > the sugested approach: > > In[1]:= $Post = ( # /. a_Real :> NumberForm[a, {32, 16}]) &; > > In[2]:= a=2. > > Out[2]//NumberForm= 2. > > In[3]:= b=3. > > Out[3]//NumberForm= 3. > > In[4]:= a*b > > Out[4]//NumberForm= 6. > > But the following form works the way I was looking > for: > > In[5]:= $Post =. > > In[6]:= $Post > > Out[6]= $Post > > In[7]:= $Post = ( # /. a_Real :> SetPrecision[a, 32]) &; > > In[8]:= a=2. > > Out[8]= 2.0000000000000000000000000000000 > > In[9]:= b=3. > > Out[9]= 3.0000000000000000000000000000000 > > In[10]:= a*b > > Out[10]= 6.0000000000000000000000000000000 > > Thanks again, > > Sergio > > On Jul 19, 4:49 am, Jens-Peer Kuska <ku... at informatik.uni-leipzig.de> > wrote: > > > Hi, > > > $Post = ( # /. a_Real :> NumberForm[a, {32, 16}]) &; > > > Regards > > Jens > > > sergi... at mail.com wrote: > > > Hello all, > > > > I am wonderin on how to change the mathematica default printing > > > precision, so I don't have to type on any defined constant the > > > required precision, like " `30 " in: > > > > In[1]:= a=2.3`30; b=2.1`30; > > > > In[2]:= a*b > > > > Out[2]= 4.83000000000000000000000000000 > > > > I would like to be able to do: > > > > a=2.3; b=2.1; and obtain > > > a*b = 4.83000000000000000000000000000 > > > > Regards, > > > > Sergio > > > PS. Apparently the internal variable $Pre could be set to do that, but > > > the respective help page [ http://reference.wolfram.com/mathematica/ref/$Pre.html > > > ] is not clear about how to do that.