IntegerDigits

IntegerDigits[n]

gives a list of the decimal digits in the integer n.

IntegerDigits[n,b]

gives a list of the base b digits in the integer n.

IntegerDigits[n,b,len]

pads the list on the left with zeros to give a list of length len.

IntegerDigits[n,MixedRadix[blist]]

uses the mixed radix with list of bases blist.

Details

  • IntegerDigits gives the most significant digit first, as in standard positional notation.
  • IntegerDigits[n] discards the sign of n.
  • If len is less than the number of digits in n, then the len least significant digits are returned.
  • IntegerDigits[0] gives {0}.
  • FromDigits can be used as the inverse of IntegerDigits.

Examples

open all close all

Basic Examples  (3)

Find digits in base 10:

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

Find digits in base 2:

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

Find digits in a mixed radix system:

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

Scope  (8)

Applications  (4)

Properties & Relations  (4)

Neat Examples  (1)

Introduced in 1991
(2.0)
|
Updated in 2015
(10.2)