IMPORTANT: To view this page as Markdown, append `.md` to the URL (e.g. /docs/manual/basics.md). For the complete Mojo documentation index, see llms.txt.
Skip to main content
Version: Nightly
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:

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:

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:

Returns:

String: A string containing the hex representation of the given bool.