def saturated
import bend-collections-laws-math@1.0.0.0/spec/math/fixed.bend as Fixedimport Base
import bend-collections-laws-math@1.0.0.0/spec/lib/common.bend as C
76# r is n when n fits w bits, and the largest w-bit value otherwise
77def saturated(+w: Nat, +n: Nat, +r: Nat, ok: Bool) -> Bool:
78 match ok:
79 case True{}:
80 Nat.is_eq(r, n)
81 case False{}:
82 Bool.and(C.fits(w, r), Bool.not(C.fits(w, 1n+r)))
Uses (6)
Used by (6)
- bend-collections-laws-math@1.0.0.0/proofs/math/typed/fixgen:sat_fit
- bend-collections-laws-math@1.0.0.0/spec/math/fixed:SaturatingAdd.value
- bend-collections-laws-math@1.0.0.0/spec/math/fixed:SaturatingMul.value
- bend-collections-laws-math@1.0.0.0/spec/math/fixed:SaturatingPow.value
- bend-collections-laws-math@1.0.0.0/proofs/math/typed/fix32:spow
- …