Skip to content

IntegerDigits

IntegerDigits[n, base] returns a list of integer digits for n under base.

Attributes[IntegerDigits] := {Listable, Protected}

Simple examples

In[1]:= IntegerDigits[123]
Out[1]= {1, 2, 3}
In[2]:= IntegerDigits[123, 2]
Out[2]= {1, 1, 1, 1, 0, 1, 1}
In[3]:= IntegerDigits[-123, 2]
Out[3]= {1, 1, 1, 1, 0, 1, 1}