Logo

Programming-Idioms

  • Ruby
  • Java

Idiom #308 Integer to string in base b

Create the string representation s of the integer value n in base b.

18 in base 3 -> "200"
26 in base 5 -> "101"
121 in base 12 -> "a1"

String s = Integer.toString(n, b);
s = n.to_s(b)

Works for radix bases up to 36.
import "strconv"
s := strconv.FormatInt(int64(n), b)

New implementation...
< >
lesmana