def saturated

bend-collections-laws-math@1.0.0.0 · spec/math/fixed.bend:76

import bend-collections-laws-math@1.0.0.0/spec/math/fixed.bend as Fixed
import 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)