THIS IS DOCUMENTATION FOR AN OBSOLETE PRODUCT.
SEE THE DOCUMENTATION CENTER FOR THE LATEST INFORMATION.

# SetPrecision

 SetPrecision[expr, p]yields a version of expr in which all numbers have been set to have precision p.
• When SetPrecision is used to increase the precision of a number, the number is padded with zeros. The zeros are taken to be in base 2. In base 10, the additional digits are usually not zeros.
• If expr contains machine-precision numbers, SetPrecision[expr, p] can give results which differ from one computer system to another.
• 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.  »
• 0.004`25 generates a number with all trailing digits zero and precision 25 on any computer system.
Convert all numbers in an expression to 20-digit precision:
Convert all numbers to machine precision:
Convert from a machine number to an arbitrary-precision number:
Convert all numbers in an expression to 20-digit precision:
 Out[1]=

Convert all numbers to machine precision:
 Out[1]=

Convert from a machine number to an arbitrary-precision number:
 Out[1]=
 Scope   (5)
Set precision of a complex number:
Convert approximate numbers to exact rational numbers:
The result has trailing zeros once any hidden digits are exposed:
SetPrecision does not affect exact powers:
This allows you to, for example, change the precision of polynomial coefficients:
Inexact powers are modified:
Special rules may apply to data objects:
For an InterpolatingFunction object, SetPrecision changes the appropriate data only:
It still works as an approximate function, but with the new precision:
 Applications   (4)
Find the roundoff error in evaluating an expression with machine numbers:
This dominates the approximation error since the increment is so small:
Find the representation error of a machine number:
The error is small because this is the closest machine number to :
The distance between nearest machine numbers is a power of two:
Raise the precision of coefficients in a differential equation to check error:
Find the solutions computed at machine precision and precision 32:
Plot the two solutions. They have deviated by t=100, indicating significant error:
Override the default accuracy and precision model:
This loses precision more slowly than the default model that treats operations as independent:
Nonetheless, all digits given are correct:
The bit loss per iteration is justified because the map is effectively a shift map:
SetPrecision just sets the precision of numbers while N works adaptively:
Since N works adaptively, the result has the requested precision of 20:
The precision is less than 20 because of the conditioning of the sine function at 1000:
SetPrecision effectively evaluates Sin with argument 1000 to precision 20:
N will typically not raise the precision of an expression, while SetPrecision will:
For nonzero numbers , SetPrecision[x, p] is equivalent to SetAccuracy[x, p-e]:
is given by RealExponent:
SetPrecision[x, ] and Rationalize[x, 0] give rational approximations for real x:
Rationalize[x, 0] gives a rational that is equivalent to x up to the precision of x:
SetPrecision[x, ] gets a rational directly from the bitwise representation of x:
SetPrecision[x, ] and give exact approximations for real x:
gives an algebraic number equivalent to x up to the precision of x:
SetPrecision[x, ] gets a rational directly from the bitwise representation of x:
SetPrecision[z, prec] will make an exact zero for approximate zeros z:
If you want an approximate zero, use SetAccuracy:
The only exception to this is that when prec is MachinePrecision, you get a machine zero: