Rounded-real semantics #
Scaled rational inputs connect to the independent real-number rounding definition roundAt
through their exponent and mantissa. The proof removes the sign, identifies the exact exponent
and scaled mantissa seen by the generic rounding theory, and proves that nearest-even quotient
selection makes the same tie decision.
For descriptors with fmt.isIEEE = true, the remaining lemmas show that an exact magnitude at
most the largest finite value produces a finite packed result.
Sign reduction #
Non-NaN scaled rational rounding restores a negative sign by exact sign-bit negation.
Rounded-real exponent and mantissa #
The absolute value of a signed scaled rational is its unsigned magnitude.
The Flocq magnitude of a nonzero scaled rational is one above its leading binary exponent,
Numerics.RationalBinary.floorLog2 numerator denominator + exponent.
The rounded-real model and rational implementation choose the same target exponent.
The canonical scaled mantissa of a rational is the same quotient after moving the selected binary exponent into its natural numerator or denominator.
Nearest-even selection of the scaled rational is roundQuotientEven, with its sign restored.
Rounded-real nearest-even semantics of a nonzero signed scaled rational.
Nearest-even scaled-rational rounding cannot overflow when the exact magnitude is at most the largest finite value of the destination format.