bit operations #
Bitwise not, usually accessed via the ~~~
prefix operator.
Interprets the integer as an infinite sequence of bits in two's complement and complements each bit.
Examples:
~~~(0 : Int) = -1
~~~(1 : Int) = -2
~~~(-1 : Int) = 0
Equations
- (Int.ofNat n).not = Int.negSucc n
- (Int.negSucc n).not = Int.ofNat n
Instances For
Equations
- Int.instComplement = { complement := Int.not }
Bitwise right shift, usually accessed via the >>>
operator.
Interprets the integer as an infinite sequence of bits in two's complement and shifts the value to the right.
Examples:
( 0b0111 : Int) >>> 1 = 0b0011
( 0b1000 : Int) >>> 1 = 0b0100
(-0b1000 : Int) >>> 1 = -0b0100
(-0b0111 : Int) >>> 1 = -0b0100
Equations
- (Int.ofNat n).shiftRight x✝ = Int.ofNat (n >>> x✝)
- (Int.negSucc n).shiftRight x✝ = Int.negSucc (n >>> x✝)
Instances For
Equations
- Int.instHShiftRightNat = { hShiftRight := Int.shiftRight }