Documentation

Batteries.Data.Int

def Int.testBit :
IntNatBool

testBit m n returns whether the (n+1) least significant bit is 1 or 0, using the two's complement convention for negative m.

Equations
Instances For
    def Int.ofBits {n : Nat} (f : Fin nBool) :

    Construct an integer from a sequence of bits using little endian convention.

    The sign is determined using the two's complement convention: the result is negative if and only if n > 0 and f (n-1) = true.

    Equations
    Instances For
      @[simp]
      theorem Int.ofBits_zero (f : Fin 0Bool) :
      ofBits f = 0
      @[simp]
      theorem Int.testBit_ofBits_lt {n i : Nat} {f : Fin nBool} (h : i < n) :
      (ofBits f).testBit i = f i, h
      @[simp]
      theorem Int.testBit_ofBits_ge {n i : Nat} {f : Fin nBool} (h : i n) :
      theorem Int.testBit_ofBits {n i : Nat} (f : Fin nBool) :
      (ofBits f).testBit i = if h : i < n then f i, h else decide (ofBits f < 0)