bit.bswap Synchronous

Reverse the order of the four bytes in a 32-bit value. Use it to convert between little-endian and big-endian representations.

Syntax
Luau
bit.bswap(value: number) -> number

Parameters

Function parameters
ParameterTypeDescription
valuenumberNumber whose four bytes should be reversed.

Returns

number

The value with its byte order reversed.

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(bit.bswap(0x12345678))) -- 78563412
Kawaii documentation