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.
The kernel is selected by intermediate capacity, not by a particular named Posit format. 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 use the two-limb primitives directly. Addition drops the carry out of the second limb and the successor wraps; 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.
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.