Direct guard-and-sticky two-limb Posit rounding #
The shared field-oriented posit rounder is instantiated with the UInt128 carrier.
candidateCarrier maps every shared operation to a two-limb primitive, and the generic kernel
in GuardStickyCarrier keeps significands and codes in UInt128. Exponents and bit counts use
Int and Nat. Only the steps with carrier-specific contracts live here: the exact
minimum-positive comparison, the zero test, and exact-width sign restoration.
Intermediate capacity selects the kernel, and no named Posit format is special. Every format
whose storage fits two words may use it whenever the exact significand is below 2^128.
Wider exact intermediates retain the same field semantics through the arbitrary-width rounder.
Shift left in the two-word bitstream, returning zero at and beyond 128 positions.
Instances For
Whether the discarded low-bit suffix is nonzero.
Instances For
Parity of the packed candidate used to break a midpoint tie.
Instances For
Two-limb implementation of the shared candidate carrier.
The transparent record lets inlined helpers specialize to the two-limb primitives. Addition drops the carry out of the second limb and the successor wraps, but the shared rounder applies both only to values it has bounded.
Instances For
Test a positive two-limb target against the format's exact minimum-positive value, a power of two, by comparing the exponent of its leading bit.
Instances For
Round the nonnegative value significand * 2 ^ exponent to its complete unsigned code in two
limbs.
Zero maps to code zero and targets below minPos to code one. Every other target uses the shared
normalized rounder at the UInt128 carrier.
Instances For
Restore a posit sign by exact-width two's complement inside the two-limb carrier.
Instances For
Round signed dyadic fields while keeping the significand and result code in two limbs.