Logo

Programming-Idioms

  • Scala
  • Python

Idiom #142 Hexadecimal digits of an integer

Assign to string s the hexadecimal representation (base 16) of integer x.

E.g. 999 -> "3e7"

s = format(x, 'x')
s = hex(x)
s = '%x' % x
val s = x.toString(16)
char s[32];
snprintf(s, sizeof(s), "%x", i);

New implementation...