and
read-only$bitwise.and(a: int, b: int) -> intPerform a bitwise and operation.
| Parameter | Type | Meaning |
|---|---|---|
a | int | First argument. |
b | int | Second argument. |
Returns int: a & b
Bit operations on integers; the language has no bitwise operators of its own.
9 natives. Read-only natives only look things up; the rest change something. Parameter types use the language's names (Types).
$bitwise.and(a: int, b: int) -> intPerform a bitwise and operation.
| Parameter | Type | Meaning |
|---|---|---|
a | int | First argument. |
b | int | Second argument. |
Returns int: a & b
$bitwise.get_bit(mask: int, index: int, check_index_range: bool, lower_bound: int, upper_bound: int) -> boolGet a bit from a given bits set. If we check index range and it's out of range, it will just return false.
| Parameter | Type | Meaning |
|---|---|---|
mask | int | The bitmask. |
index | int | The bit index to set. |
check_index_range | bool | Whether we should check range [lower_bound, upper_bound] for the input index. |
lower_bound | int | The lower bound for index. |
upper_bound | int | The upper bound for index. |
Returns bool: The value of the bit. True is 1 and false is 0.
$bitwise.get_set_count(mask: int) -> intCount the number of bits set.
| Parameter | Type | Meaning |
|---|---|---|
mask | int | The bitmask. |
Returns int: The number of bits set.
$bitwise.not(a: int) -> intPerform a bitwise not operation.
| Parameter | Type | Meaning |
|---|---|---|
a | int | Argument. |
Returns int: ~a
$bitwise.or(a: int, b: int) -> intPerform a bitwise or operation.
| Parameter | Type | Meaning |
|---|---|---|
a | int | First argument. |
b | int | Second argument. |
Returns int: a | b
$bitwise.set_bit(mask: int, index: int, value: bool, check_index_range: bool, lower_bound: int, upper_bound: int) -> intSet a bit in a given bits set and return the bits set. If we check index range and it's out of range, it will just return the input bits set.
| Parameter | Type | Meaning |
|---|---|---|
mask | int | The bitmask. |
index | int | The bit index to set. |
value | bool | The bit value to set. True is 1, and false is 0. |
check_index_range | bool | Whether we should check range [lower_bound, upper_bound] for the input index. |
lower_bound | int | The lower bound for index. |
upper_bound | int | The upper bound for index. |
Returns int: The result of bits set.
$bitwise.shift_left(a: int, b: int) -> intPerform a bitwise shift left operation.
| Parameter | Type | Meaning |
|---|---|---|
a | int | First argument. |
b | int | Second argument. |
Returns int: a << b
$bitwise.shift_right(a: int, b: int) -> intPerform an UNSIGNED bitwise shift right operation.
| Parameter | Type | Meaning |
|---|---|---|
a | int | First argument. |
b | int | Second argument. |
Returns int: a >> b
$bitwise.xor(a: int, b: int) -> intPerform a bitwise xor operation.
| Parameter | Type | Meaning |
|---|---|---|
a | int | First argument. |
b | int | Second argument. |
Returns int: a ^ b