Bit operations on natural numbers #
Naming convention:
- ..._getBit_1 or _eq_one : the value of getBit is 1 at the specified bit(s)
- getBit_of_... : the value of getBit is the value of the specified bit(s), under some preconditions
Returns the k-th least significant bit of a natural number n as a natural number (in {0, 1}).
We decompose each number j < 2^ℓ into its binary representation : j = Σ k ∈ Fin ℓ, jₖ * 2ᵏ
Equations
Instances For
Get the numLowBits least significant bits of n.
Equations
Instances For
This takes a argument for the number of lowBitss to remove from the number
Equations
Instances For
Middle bits: take len bits starting at offset from n.
Equations
Instances For
Middle bits are strictly less than 2^len.
Middle bits as a modulus form.