## 3.1.3 Digits in Numbers

 IntegerDigits[n] a list of the decimal digits in the integer n IntegerDigits[n, b] the digits of n in base b IntegerDigits[n, b, len] the list of digits padded on the left with zeros to give total length len IntegerExponent[n, b] the number of zeros at the end of n in base b RealDigits[x] a list of the decimal digits in the approximate real number x, together with the number of digits to the left of the decimal point RealDigits[x, b] the digits of x in base b RealDigits[x, b, len] the first len digits of x in base b RealDigits[x, b, len, n] the first len digits starting with the coefficient of FromDigits[list] reconstruct a number from its decimal digit sequence FromDigits[list, b] reconstruct a number from its digit sequence in base b

Converting between numbers and lists of digits.
Here is the list of base 16 digits for an integer.
 In[1]:=  IntegerDigits[1234135634, 16]
 Out[1]=
This gives a list of digits, together with the number of digits that appear to the left of the decimal point.
 In[2]:=  RealDigits[123.4567890123456]
 Out[2]=
Here is the binary digit sequence for 56, padded with zeros so that it is of total length 8.
 In[3]:=  IntegerDigits[56, 2, 8]
 Out[3]=
This reconstructs the original number from its binary digit sequence.
 In[4]:=  FromDigits[%, 2]
 Out[4]=

 b^^nnnn a number in base b BaseForm[x, b] print with x in base b

Numbers in other bases.

When the base is larger than 10, extra digits are represented by letters a-z.

The number in base 2 is in base 10.
 In[5]:=  2^^100101
 Out[5]=
This prints in base 2.
 In[6]:=  BaseForm[37, 2]
 Out[6]//BaseForm=
Here is a number in base 16.
 In[7]:=  16^^ffffaa00
 Out[7]=
You can do computations with numbers in base 16. Here the result is given in base 10.
 In[8]:=  16^^fffaa2 + 16^^ff - 1
 Out[8]=
This gives the result in base 16.
 In[9]:=  BaseForm[%, 16]
 Out[9]//BaseForm=
You can give approximate real numbers, as well as integers, in other bases.
 In[10]:=  2^^101.100101
 Out[10]=
Here are the first few digits of in octal.
 In[11]:=  BaseForm[N[Sqrt[2], 30], 8]
 Out[11]//BaseForm=
This gives an explicit list of the first 15 octal digits.
 In[12]:=  RealDigits[Sqrt[2], 8, 15]
 Out[12]=
This gives 15 octal digits starting with the coefficient of .
 In[13]:=  RealDigits[Sqrt[2], 8, 15, -10]
 Out[13]=

Section 2.9.7 describes how to print numbers in various formats. If you want to create your own formats, you will often need to use MantissaExponent to separate the pieces of real numbers.

 MantissaExponent[x] give a list containing the mantissa and exponent of x MantissaExponent[x, b] give the mantissa and exponent in base b

Separating the mantissa and exponent of numbers.
This gives a list in which the mantissa and exponent of the number are separated.
 In[14]:=  MantissaExponent[3.45 10^125]
 Out[14]=

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