bit.shl
Lua function

bit.shl

Summary

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



See Also ...

Topics

DOC_lua_base Lua base functions
DOC_lua_bc Lua bc (big number) functions
DOC_lua_bit Lua bit manipulation functions
DOC_lua_coroutines Lua coroutine functions
DOC_lua_debug Lua debug functions
DOC_lua_io Lua io functions
DOC_lua_math Lua math functions
DOC_lua_os Lua os functions
DOC_lua_package Lua package functions
DOC_lua_rex Lua PCRE regular expression functions
DOC_lua Lua script extensions
DOC_lua_string Lua string functions
DOC_lua_tables Lua table functions
DOC_lua_utils Lua utilities
DOC_scripting Scripting

Lua functions

LUA_bit.ashr bit.ashr (Shifts a number right, preserving sign)
LUA_bit.band bit.band (Bitwise 'and')
LUA_bit.bor bit.bor (Bitwise 'or')
LUA_bit.mod bit.mod (Bitwise 'modulus' (remainder after integer divide))
LUA_bit.neg bit.neg (Bitwise negate (ones complement))
LUA_bit.shr bit.shr (Shifts a number right)
LUA_bit.tonumber bit.tonumber (Convert a string into a number)
LUA_bit.tostring bit.tostring (Convert a number into a string)
LUA_bit.xor bit.xor (Bitwise 'exclusive or')

(Help topic: lua=bit.shl)

DOC_contents Documentation contents page