Skip to content

IntegerDigits

The digits of n in the given base (default 10), most significant first.

WikipediaNumerical digitMathWorldDigitWikidataQ82990Wolfram LanguageIntegerDigitsRosetta CodeSum digits of an integer
IntegerDigits(n)digits of in base 10, most significant first.
IntegerDigits(n, base)digits of in the given base.
IntegerDigits(n, base, len)the least-significant digits, zero-padded if needed.

Domain: Number theory

Details
  • Digits come out most significant first, matching ordinary positional notation.
  • The sign of n is discarded, so negative integers give the same digits as their absolute value.
  • IntegerDigits(0) is -- there's always at least one digit.
  • The 3-argument form keeps only the len least-significant digits, truncating or zero-padding as needed.
  • Inverted by FromDigits.

Examples

See also: DigitCount, FromDigits, IntegerString