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.
  • SetPrecision returns an arbitraryprecision number, even if the precision requested is less than $MachinePrecision.
  • SetPrecision[expr,MachinePrecision] converts numbers in expr to machine precision.
  • If there are numbers too large or small to represent machine-precision numbers, SetPrecision[expr,MachinePrecision] will convert them to arbitrary-precision numbers with precision $MachinePrecision.
  • If expr contains machineprecision numbers, SetPrecision[expr,p] can give results that 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.
  • SetPrecision[expr,p] does not modify expr itself.


open all close all

Basic Examples  (3)

Convert all numbers in an expression to 20-digit precision:

Click for copyable input

Convert all numbers to machine precision:

Click for copyable input

Convert from a machine number to an arbitrary-precision number:

Click for copyable input

Scope  (5)

Applications  (4)

Properties & Relations  (5)

Possible Issues  (1)

Introduced in 1991
Updated in 2003