Module nixio.bit
Bitfield operators and mainpulation functions.
Can be used as a drop-in replacement for bitlib.
Functions
bor (oper1, oper2, ...) | Bitwise OR several numbers. |
bnot (oper) | Invert given number. |
band (oper1, oper2, ...) | Bitwise AND several numbers. |
bxor (oper1, oper2, ...) | Bitwise XOR several numbers. |
lshift (oper, shift) | Left shift a number. |
rshift (oper, shift) | Right shift a number. |
arshift (oper, shift) | Arithmetically right shift a number. |
div (oper1, oper2, ...) | Integer division of 2 or more numbers. |
cast (oper) | Cast a number to the bit-operating range. |
set (bitfield, flag1, ...) | Sets one or more flags of a bitfield. |
unset (bitfield, flag1, ...) | Unsets one or more flags of a bitfield. |
check (bitfield, flag1, ...) | Checks whether given flags are set in a bitfield. |
Functions
- bor (oper1, oper2, ...)
-
Bitwise OR several numbers.
Parameters:
- oper1 First Operand
- oper2 Second Operand
- ... More Operands
Returns:
-
number
- bnot (oper)
-
Invert given number.
Parameters:
- oper Operand
Returns:
-
number
- band (oper1, oper2, ...)
-
Bitwise AND several numbers.
Parameters:
- oper1 First Operand
- oper2 Second Operand
- ... More Operands
Returns:
-
number
- bxor (oper1, oper2, ...)
-
Bitwise XOR several numbers.
Parameters:
- oper1 First Operand
- oper2 Second Operand
- ... More Operands
Returns:
-
number
- lshift (oper, shift)
-
Left shift a number.
Parameters:
- oper number
- shift bits to shift
Returns:
-
number
- rshift (oper, shift)
-
Right shift a number.
Parameters:
- oper number
- shift bits to shift
Returns:
-
number
- arshift (oper, shift)
-
Arithmetically right shift a number.
Parameters:
- oper number
- shift bits to shift
Returns:
-
number
- div (oper1, oper2, ...)
-
Integer division of 2 or more numbers.
Parameters:
- oper1 Operand 1
- oper2 Operand 2
- ... More Operands
Returns:
-
number
- cast (oper)
-
Cast a number to the bit-operating range.
Parameters:
- oper number
Returns:
-
number
- set (bitfield, flag1, ...)
-
Sets one or more flags of a bitfield.
Parameters:
- bitfield Bitfield
- flag1 First Flag
- ... More Flags
Returns:
-
altered bitfield
- unset (bitfield, flag1, ...)
-
Unsets one or more flags of a bitfield.
Parameters:
- bitfield Bitfield
- flag1 First Flag
- ... More Flags
Returns:
-
altered bitfield
- check (bitfield, flag1, ...)
-
Checks whether given flags are set in a bitfield.
Parameters:
- bitfield Bitfield
- flag1 First Flag
- ... More Flags
Returns:
-
true when all flags are set, otherwise false