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

Idiom #142 Hexadecimal digits of an integer

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

E.g. 999 -> "3e7"

import "strconv"
s := strconv.FormatInt(x, 16)
import "fmt"
import "math/big"
s := fmt.Sprintf("%x", x)
char s[32];
snprintf(s, sizeof(s), "%x", i);
String s = x.ToString("x")
import std.conv;
s = to!string(x, 16);
import std.format;
s = format("%x", x);
s = string.format("%x",x)
<?php

$s = dechex(999);
uses sysutils;
s := IntToHex(x);
s = format(x, 'x')
s = x.to_s(16)
let s = format!("{:X}", x);

Do you know the best way to do this in your language ?
New implementation...

Idiom created by

programming-idioms.org

Related idioms