For the complete Mojo documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /docs/manual/basics.md).
hex
hex(value: Scalar, /, *, prefix: StringSlice[StaticConstantOrigin] = StringSlice("0x")) -> String
Returns the hex string representation of the given integer.
The hexadecimal representation is a base-16 encoding of the integer value.
The returned string will be prefixed with "0x" to indicate that the subsequent digits are hex.
Args:
- value (
Scalar): The integer value to format. - prefix (
StringSlice[StaticConstantOrigin]): The prefix of the formatted int.
Returns:
String: A string containing the hex representation of the given integer.
hex[T: Intable, //](value: T, /, *, prefix: StringSlice[StaticConstantOrigin] = StringSlice("0x")) -> String
Returns the hex string representation of the given integer.
The hexadecimal representation is a base-16 encoding of the integer value.
The returned string will be prefixed with "0x" to indicate that the subsequent digits are hex.
Parameters:
- T (
Intable): The indexer type to represent in hexadecimal.
Args:
- value (
T): The integer value to format. - prefix (
StringSlice[StaticConstantOrigin]): The prefix of the formatted int.
Returns:
String: A string containing the hex representation of the given integer.
hex(value: Scalar[DType.bool], /, *, prefix: StringSlice[StaticConstantOrigin] = StringSlice("0x")) -> String
Returns the hex string representation of the given scalar bool.
The hexadecimal representation is a base-16 encoding of the bool.
The returned string will be prefixed with "0x" to indicate that the subsequent digits are hex.
Args:
- value (
Scalar[DType.bool]): The bool value to format. - prefix (
StringSlice[StaticConstantOrigin]): The prefix of the formatted int.
Returns:
String: A string containing the hex representation of the given bool.