Logo

Programming-Idioms

This language bar is your friend. Select your favorite languages!
  • Ruby

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"

s = n.to_s(b)

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

New implementation...
< >
lesmana