bit.lshift Synchronous

Move bits left and fill the low positions with zeroes, discarding overflow. Use it to place a number into a higher bit field.

Syntax
Luau
bit.lshift(value: number, count: number) -> number

Parameters

Function parameters
ParameterTypeDescription
valuenumberFinite number to truncate and interpret as an unsigned 32-bit value.
countnumberShift or rotation count, normalized to 32 bits and masked with 31. Counts 32 and 0 therefore perform the same operation.

Returns

number

The resulting unsigned 32-bit value.

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
local packed = bit.bor(bit.lshift(0x12, 8), 0x34)
print(bit.tohex(packed)) -- 1234
Kawaii documentation