MATHEMATICA HOW TO

# How to | Change the Format of Numbers

While there is typically one representation for exact numbers, approximate numbers can be presented differently according to the conventions of different professions or personal preference. Mathematica provides several ways to control the display of these numbers. Options for displaying numbers can also be specified by selecting the Numbers tab from Appearance in the Edit ► Preferences window.

Enter an integer:

 Out[50]=

Enter a rational number as the ratio of two integers. Mathematica automatically cancels the common factors:

 Out[51]=

Enter an approximate real number by explicitly including a decimal point:

 Out[52]=

Enter a complex number:

 Out[53]=

Make a complex number with rational components:

 Out[54]=

Complex numbers can have mixed components:

 Out[1]=

To display an exact real number with a decimal point, turn it into an approximate real number. Here N turns into an approximate real number:

 Out[56]=

Also, any calculation mixing exact and approximate numbers gives an approximate result:

 Out[57]=

NumberForm displays a number to a given number of significant digits:

 Out[58]//NumberForm=

You can request n significant digits and k digits to the right of the decimal point by using the form NumberForm[expr, {n, k}]. If the digits are not known they are filled in with zeros:

 Out[59]//NumberForm=

If you use Mathematica for accounting, use AccountingForm:

 Out[60]//AccountingForm=
 Out[61]//AccountingForm=
 Out[62]//AccountingForm=

For scientific calculations, use ScientificForm:

 Out[63]//ScientificForm=

You can also use EngineeringForm:

 Out[64]//EngineeringForm=

To change base, use BaseForm:

 Out[65]//BaseForm=

None of these forms allow further calculation; they are used for final display in tables, labels, and so on:

 Out[66]=