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. The Wolfram Language 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:

In[1]:=
Click for copyable input
Out[1]=

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

In[2]:=
Click for copyable input
Out[2]=

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

In[3]:=
Click for copyable input
Out[3]=

Enter a complex number:

In[4]:=
Click for copyable input
Out[4]=

Make a complex number with rational components:

In[5]:=
Click for copyable input
Out[5]=

Complex numbers can have mixed components:

In[6]:=
Click for copyable input
Out[6]=
    

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:

In[1]:=
Click for copyable input
Out[1]=

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

In[2]:=
Click for copyable input
Out[2]=

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

In[3]:=
Click for copyable input
Out[3]//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:

In[4]:=
Click for copyable input
Out[4]//NumberForm=

If you use the Wolfram Language for accounting, use AccountingForm:

In[5]:=
Click for copyable input
Out[5]//AccountingForm=
Out[5]//AccountingForm=
Out[5]//AccountingForm=

For scientific calculations, use ScientificForm:

In[6]:=
Click for copyable input
Out[6]//ScientificForm=

You can also use EngineeringForm:

In[7]:=
Click for copyable input
Out[7]//EngineeringForm=
    

To change base, use BaseForm:

In[1]:=
Click for copyable input
Out[1]//BaseForm=
    

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

In[1]:=
Click for copyable input
Out[1]=