Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
1990
*January
*February
*March
*April
*May
*June
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 1990

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

Search the Archive

SetPrecision[]

  • To: mathgroup at yoda.ncsa.uiuc.edu
  • Subject: SetPrecision[]
  • From: uunet!yoda.ncsa.uiuc.edu!keiper%wri (Jerry Keiper)
  • Date: Mon, 2 Apr 90 17:24:41 CDT

Jeffrey P. Golden <uiucuxc!ALLEGHENY.SCRC.Symbolics.COM!jpg> writes:
   >If the user types SetPrecision[1.2,30], I think it is pretty clear
   >that most users mean the same number that SetPrecision[12/10,30]
   >would mean, i.e. fill in with decimal 0's, which is not what
   >Mathematica does.

Since that sort of functionality is in general impossible, I presume that
the suggestion is only intended to make it more convenient to enter
numbers precisely.  But the 1.2 will have been converted to 1.001100110011...
long before SetPrecision[] ever even gets to look at it.  If the above
functionality is desired one can do something like

	HighPrecision[x_, n_] := SetPrecision[Rationalize[x], n]

then
In[9]:= HighPrecision[1.2,40]

Out[9]= 1.2
 
In[10]:= SetPrecision[%, 60]

Out[10]= 1.19999999999999999999999999999999999999999999999917892668106

But this will only work for numbers that are essentially rational numbers
with relatively small denominators with a small rounding error thrown in
to allow it to be represented in binary.

I do not think that overloading SetPrecision[] to have this functionality
is appropriate.

Jerry Keiper
keiper at wri.com
Wolfram Research Inc.



  • Next by Date: precision and accuracy
  • Next by thread: Re: SetPrecision[]