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.
testBit m n
returns whether the (n+1)ˢᵗ
least significant bit is 1
or 0
Equations
- Int.testBit x✝ x = match x✝, x with | Int.ofNat m, n => Nat.testBit m n | Int.negSucc m, n => !Nat.testBit m 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
- Int.lnot x = 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.instShiftRightInt = { shiftRight := fun (m n : ℤ) => m <<< (-n) }