bit.ashr
Shifts a number right, preserving sign
Prototype
n = bit.ashr (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 right the number of bits in the second argument.
Use this version for shifting signed numbers right, as it preserves the sign. (The other version, bit.shr, will shift the sign bit into the number part).
eg.
Use this version for shifting signed numbers right, as it preserves the sign. (The other version, bit.shr, will shift the sign bit into the number part).
eg.
print (bit.ashr (-1024, 6)) --> -16
Lua functions
- bit.band - Bitwise 'and'
- bit.bor - Bitwise 'or'
- bit.clear - Clears one or more bits
- bit.mod - Bitwise 'modulus' (remainder after integer divide)
- bit.neg - Bitwise 'negate' (ones complement)
- bit.shl - Shifts a number left
- bit.shr - Shifts a number right
- bit.test - Bitwise 'test'
- bit.tonumber - Convert a string into a number
- bit.tostring - Convert a number into a string
- bit.xor - Bitwise 'exclusive or'
Topics
- Lua LPEG library
- Lua PCRE regular expression functions
- Lua base functions
- Lua bc (big number) functions
- Lua bit manipulation functions
- Lua coroutine functions
- Lua debug functions
- Lua io functions
- Lua math functions
- Lua os functions
- Lua package functions
- Lua script extensions
- Lua string functions
- Lua syntax
- Lua table functions
- Lua utilities
- Scripting callbacks - plugins
- Scripting