Bitwise operations on integers #
Possibly only of archaeological significance.
Recursors #
Int.bitCasesOn
: Parity disjunction. Something is true/defined onℤ
if it's true/defined for even and for odd values.
div2 n = n/2
Equations
- x.div2 = match x with | Int.ofNat n => ↑n.div2 | Int.negSucc n => Int.negSucc n.div2
Instances For
testBit m n
returns whether the (n+1)ˢᵗ
least significant bit is 1
or 0
Equations
- x✝.testBit x = match x✝, x with | Int.ofNat m, n => m.testBit n | Int.negSucc m, n => !m.testBit n
Instances For
Int.natBitwise
is an auxiliary definition for Int.bitwise
.
Equations
- Int.natBitwise f m n = bif f false false then Int.negSucc (Nat.bitwise (fun (x y : Bool) => !f x y) m n) else ↑(Nat.bitwise f m n)
Instances For
Int.bitwise
applies the function f
to pairs of bits in the same position in
the binary representations of its inputs.
Equations
- One or more equations did not get rendered due to their size.
Instances For
lnot
flips all the bits in the binary representation of its input
Equations
- x.lnot = match x with | Int.ofNat m => Int.negSucc m | Int.negSucc m => ↑m
Instances For
ldiff a b
performs bitwise set difference. For each corresponding
pair of bits taken as booleans, say aᵢ
and bᵢ
, it applies the
boolean operation aᵢ ∧ bᵢ
to obtain the iᵗʰ
bit of the result.
Equations
- One or more equations did not get rendered due to their size.
Instances For
m <<< n
produces an integer whose binary representation
is obtained by left-shifting the binary representation of m
by n
places
Equations
- One or more equations did not get rendered due to their size.
m >>> n
produces an integer whose binary representation
is obtained by right-shifting the binary representation of m
by n
places
Equations
- Int.instShiftRight_mathlib = { shiftRight := fun (m n : ℤ) => m <<< (-n) }
bitwise ops #
bitwise ops #
Compare with Int.zero_shiftRight
, which has n : ℕ
.