law to_nat_and_mask
import lawful-words@0.1.0.0/LAWS.bend as LAWSimport Base
251# And with a mask of the low k bits takes the number modulo 2^k. The mask is
252# any word standing for 2^k - 1, so a literal such as 255 or 3 qualifies. No
253# word stands for 2^k - 1 when k > 32, so in practice k <= 32 (k = 32 is the
254# all-ones word).
255law to_nat_and_mask:
256 for a: U32
257 for m: U32
258 for k: Nat
259 for h: {U32.to_nat(m) == Nat.sub(Nat.pow(2n, k), 1n) : Nat}
260 {U32.to_nat(U32.and(a, m)) == Nat.mod(U32.to_nat(a), Nat.pow(2n, k)) : Nat}
Uses (8)
Used by (0)
No other definition uses this definition.