Primitive carriers for fixed-word posit kernels #
The four built-in posit carriers differ only in how they widen to and narrow from UInt64.
Carrier records that relationship once. It is passed only to always-inlined helpers; the public
raw kernels remain monomorphic so their native calling conventions are unchanged.
Arithmetic view of one primitive unsigned carrier.
- toNat : α → ℕ
Observe the encoded natural number.
- toUInt64 : α → UInt64
Zero-extend the carrier to the packed arithmetic word.
- narrow : UInt64 → α
Narrow a packed arithmetic result back to the carrier.
- ofNat : ℕ → α
Construct the carrier from a natural number.
- toNat_injective : Function.Injective self.toNat
Natural-number observation determines the primitive carrier.
Widening preserves the represented natural number.
Narrowing is reduction modulo the carrier capacity.
Natural construction is reduction modulo the carrier capacity.
Fixed-word carriers fit in the packed
UInt64arithmetic word.
Instances For
UInt8 as a packed posit carrier.
This is an abbreviation so monomorphic raw kernels reduce its projections at compile time instead of loading conversion closures from a runtime record.
Instances For
UInt32 as a packed posit carrier.
Keeping the carrier transparent lets widening and narrowing compile to primitive operations.