bitops
Bit Manipulation Utilities
Functions
| Function | Description |
|---|---|
bit_pow2 | Internal: power of 2 lookup. |
bit_shl | Left shift: a « n. |
bit_shr | Logical right shift: a »> n (unsigned). |
bit_and | Bitwise AND via arithmetic decomposition. |
bit_or | Bitwise OR via arithmetic decomposition. |
bit_xor | Bitwise XOR via arithmetic decomposition. |
bit_not | Bitwise NOT (ones complement, 64-bit). |
bit_get | Get bit n of a (0 or 1). |
bit_set | Set bit n of a to 1. |
bit_clear | Clear bit n of a to 0. |
bit_toggle | Toggle bit n of a. |
bit_count | Population count (number of 1 bits). |
bit_leading_zeros | Number of leading zero bits (from MSB). |
bit_trailing_zeros | Number of trailing zero bits (from LSB). |
bit_reverse | Reverse bit order. |
bit_rotl | Rotate left by n positions. |
bit_rotr | Rotate right by n positions. |
Details
bit_pow2
fn bit_pow2(n: i64) -> i64Internal: power of 2 lookup.
bit_shl
fn bit_shl(a: i64, n: i64) -> i64Left shift: a « n.
bit_shr
fn bit_shr(a: i64, n: i64) -> i64Logical right shift: a »> n (unsigned).
bit_and
fn bit_and(a: i64, b: i64) -> i64Bitwise AND via arithmetic decomposition.
bit_or
fn bit_or(a: i64, b: i64) -> i64Bitwise OR via arithmetic decomposition.
bit_xor
fn bit_xor(a: i64, b: i64) -> i64Bitwise XOR via arithmetic decomposition.
bit_not
fn bit_not(a: i64) -> i64Bitwise NOT (ones complement, 64-bit).
bit_get
fn bit_get(a: i64, n: i64) -> i64Get bit n of a (0 or 1).
bit_set
fn bit_set(a: i64, n: i64) -> i64Set bit n of a to 1.
bit_clear
fn bit_clear(a: i64, n: i64) -> i64Clear bit n of a to 0.
bit_toggle
fn bit_toggle(a: i64, n: i64) -> i64Toggle bit n of a.
bit_count
fn bit_count(a: i64) -> i64Population count (number of 1 bits).
bit_leading_zeros
fn bit_leading_zeros(a: i64) -> i64Number of leading zero bits (from MSB).
bit_trailing_zeros
fn bit_trailing_zeros(a: i64) -> i64Number of trailing zero bits (from LSB).
bit_reverse
fn bit_reverse(a: i64) -> i64Reverse bit order.
bit_rotl
fn bit_rotl(a: i64, n: i64) -> i64Rotate left by n positions.
bit_rotr
fn bit_rotr(a: i64, n: i64) -> i64Rotate right by n positions.