bit.shl

Shifts a number left

Prototype

n = bit.shl (num, bits)

Description

This takes two arguments. The first is converted to signed 'long long' (64-bit integer), the second to unsigned 'long long' (64-bit unsigned integer). The first argument is shifted left the number of bits in the second argument.

You can use this for signed or unsigned numbers, as the sign bit will still be preserved.

eg.

print (bit.shl (4, 6)) --> 256

Lua functions

Topics