bit.tohex Synchronous

Show the unsigned 32-bit representation of a number as lowercase hexadecimal. It is convenient when inspecting flags, packet fields, or the result of a byte swap.

Syntax
Luau
bit.tohex(value: number, ...ignored: any) -> string

Parameters

Function parameters
ParameterTypeDescription
valuenumberFinite number to normalize to 32 bits.
...ignoredanyAdditional arguments are ignored. A width or padding option is not implemented.

Returns

string

Lowercase hexadecimal text without leading zero padding.

Usage notes

This always describes the unsigned 32-bit value, even when the input number was negative.

Differences from Volt

Volt documents its Bit Library setting as disabled by default. Kawaii enables bit by default. Disabling the setting removes the bit global and makes retained function references reject calls.

Availability

Bit is enabled by default. The bit global is removed when disabled, and its operations check the setting.

Example

Example
Luau
print(bit.tohex(255)) -- ff
print(bit.tohex(-1)) -- ffffffff
Kawaii documentation