Bit Library
bdiv
<int> bit.bdiv(<uint> dividend, <uint> divisor)
Divides dividend
by divisor
, remainder is not returned.
badd
<int> bit.badd(<uint> a, <uint> b)
Adds a
with b
, allows overflows.
bsub
<int> bit.bsub(<uint> a, <uint> b)
Subtracts a
with b
, allows overflows.
bmul
<int> bit.bmul(<uint> val, <uint> by)
Multiplies val
using by
, allows overflows.
Note: All bitwise functions within the bit
lib return signed 32 bit integers. Take good note of that when implementing. If you want unsigned results, we suggest using bit32
.
band
<int> bit.band(<uint> val, <uint> by)
Does a bitwise AND (&) on val
using by
.
bor
<int> bit.bor(<uint> val, <uint> by)
Does a bitwise OR (|) on val
using by
.
bxor
<int> bit.bxor(<uint> val, <uint> by)
Does a bitwise XOR (⊕) on val
using by
.
bnot
<int> bit.bnot(<uint> val)
Does a bitwise NOT on val
.
bswap
<int> bit.bswap(<uint> val)
Does a bitwise swap on val
.
ror
<int> bit.rol(<int> value, <int> rotate_count)
Returns the value
rotated right by rotate_count
.
rol
<int> bit.rol(<int> value, <int> rotate_count)
Returns the value
rotated left by rotate_count
.
tohex
<string> bit.tohex(<uint> val)
Converts val
to a hex string.
tobit
<int> bit.tobit(<uint> val)
Converts val
into proper form for bitwise operations.
lshift
<int> bit.lshift(<uint> val, <uint> by)
Does a left shift on val
using by
.
rshift
<int> bit.rshift(<uint> val, <uint> by)
Does a right shift on val using by.
arshift
<int> bit.arshift(<int> value, <int> shift_count)
Returns the arithmetically shifted value.