HomeManualTopicsTypesSymbols

std::hex

converts a positive integer value into a string consisting of hexadecimal digits

Parameters

val
the value to convert
size (default: undefined)
the optional minimum length

Result

string
a string consisting of hexadecimal digits

Description

The optional second parameter specifies the minimum length of the resulting string. If there are fewer hexadecimal digits than the specified length, the string is left-padded with zeros.

Example

println! hex(123)

Output

7b

Example

println! hex(123 4)

Output

007b

Topics

Math

Strings

See also

std::bin converts a positive integer value into a string consisting of binary digits
std::oct converts a positive integer value into a string consisting of octal digits
std::to_string returns a human readable presentation of the object