@[extern lean_nat_shiftl]
Shifts the binary representation of a value left by the specified number of bits. Usually accessed
via the <<<
operator.
Examples:
1 <<< 2 = 4
1 <<< 3 = 8
0 <<< 3 = 0
0xf1 <<< 4 = 0xf10
@[extern lean_nat_shiftr]
Shifts the binary representation of a value right by the specified number of bits. Usually accessed
via the >>>
operator.
Examples:
4 >>> 2 = 1
8 >>> 2 = 2
8 >>> 3 = 1
0 >>> 3 = 0
0xf13a >>> 8 = 0xf1
Equations
- x✝.shiftRight 0 = x✝
- x✝.shiftRight m.succ = x✝.shiftRight m / 2
Equations
- Nat.instShiftLeft = { shiftLeft := Nat.shiftLeft }
Equations
- Nat.instShiftRight = { shiftRight := Nat.shiftRight }
testBit #
We define an operation for testing individual bits in the binary representation of a number.