Skip to content

IntegerString ​

The string representation of n in the given base (default 10).

✓ checked against that system · ! checked, with disagreements (hover a chip)Wolfram LanguageIntegerString!
IntegerString(n)string form of nn in base 10.
IntegerString(n, base)string form of nn in the given base, up to base 36.
IntegerString(n, base, length)padded with leading zeros to exactly length digits, or cut to the last length.
IntegerString(n, "Roman")the Roman numeral for n, same as RomanNumeral.
Typed signatures
TypePackageApplies
(integer, integer?) -> stringcompute-enginealways
(integer, (integer | string)?, integer?) -> stringnumeralsreplaces compute-enginealways

Domain: Numeral systems

Details
  • Bases above 10 use letters a-z for digit values beyond 9, up to base 36.
  • compute-engine keeps a leading minus sign for negative n
  • A third argument pads with leading zeros to that length, or keeps only the last that many digits; with it, a negative n is left unevaluated (Wolfram drops the sign, compute-engine keeps it).
  • compute-engine's second argument is always a numeric base.

Examples

Basic #
live ↗
InIntegerString(42)\mathrm{IntegerString}(42)Out42\text{42}
live ↗
InIntegerString(17 651,2)\mathrm{IntegerString}(17\,651, 2)Out100010011110011\text{100010011110011}

Bases above 10 use letters a-z

live ↗
InIntegerString(255,16)\mathrm{IntegerString}(255, 16)Outff\text{ff}
Scope #

base 36 is the largest, with digit values up to z

live ↗
InIntegerString(35,36)\mathrm{IntegerString}(35, 36)Outz\text{z}

Threads over a list

live ↗
InIntegerString([1,2,3])\mathrm{IntegerString}(\bigl\lbrack1, 2, 3\bigr\rbrack)Out[1,2,3]\bigl\lbrack\text{1}, \text{2}, \text{3}\bigr\rbrack

50!50! in hexadecimal: exact past double precision, via bigint arithmetic

live ↗
InIntegerString(50!,16)\mathrm{IntegerString}(50!, 16)Out49eebc961ed279b02b1ef4f28d19a84f5973a1d2c7800000000000\text{49eebc961ed279b02b1ef4f28d19a84f5973a1d2c7800000000000}

Roman numerals, with the base "Roman"

live ↗
InIntegerString(1 988,Roman)\mathrm{IntegerString}(1\,988, \text{Roman})OutMCMLXXXVIII\text{MCMLXXXVIII}

a width pads with leading zeros

live ↗
InIntegerString(255,16,4)\mathrm{IntegerString}(255, 16, 4)Out00ff\text{00ff}

a width shorter than the numeral keeps the least-significant digits

live ↗
InIntegerString(1 234 567,10,3)\mathrm{IntegerString}(1\,234\,567, 10, 3)Out567\text{567}

A third argument pads with leading zeros to that length (or keeps only the last that many digits)

live ↗
InIntegerString(5,2,8)\mathrm{IntegerString}(5, 2, 8)Out00000101\text{00000101}

A large factorial in base 36 uses digits and letters; many trailing zeros

live ↗
InIntegerString(50!,36)\mathrm{IntegerString}(50!, 36)Out4q7eyp9zizmtqt0648txt4fm720cc1s00000000000\text{4q7eyp9zizmtqt0648txt4fm720cc1s00000000000}
Properties #

2046=211−22046=2^{11}-2 is ten ones then a zero in binary

live ↗
InIntegerString(2 046,2)\mathrm{IntegerString}(2\,046, 2)Out11111111110\text{11111111110}
Possible issues #
live ↗
InIntegerString(0)\mathrm{IntegerString}(0)Out0\text{0}

compute-engine keeps the sign

live ↗
InIntegerString(−42)\mathrm{IntegerString}(-42)Out-42\text{-42}
About
Examples14
Checked againstWolfram Language 13 agree1 differ
CrosswalkWolfram Language

See also: IntegerDigits