Exact-rational P3109 projection #
Configured binary floats, posits, integer inputs, and exact finite arithmetic can all supply exact rational values. This module projects them directly into any valid P3109 descriptor, rounding from the numerator and denominator without an intermediate approximation.
The runtime follows the same P3109 projection order as dyadic projection:
- select the descriptor quantum;
- round the exact quotient according to the requested P3109 mode;
- apply the shared saturation rule;
- encode the resulting datum directly.
The dyadic entry point remains useful when the caller already owns an exact binary value. Both paths share saturation, encoding, and descriptor logic.
Floor of (remainder / denominator) * 2^outputBits.
Instances For
Nearest-even integer to (remainder / denominator) * 2^outputBits.
Instances For
Decide whether exact rational rounding selects the integer above the quotient floor.
denominator is positive for every Rat. Keeping it explicit makes the stochastic formulas
match P3109 Section 4.7.4 directly.
Instances For
P3109 rational rounding uses the descriptor's code parity, including precision one.
Instances For
Round one exact finite rational to the descriptor's P3109 precision.
The selected quantum is
max(floor(log2 |x|), 1 - B) - P + 1. Scaling by the opposite quantum turns the rounding decision
into one natural-number quotient and remainder. The result is an exact dyadic datum on the P3109
precision grid.
Instances For
Apply P3109 precision rounding to an exact-rational closed value.
Instances For
Exact-rational P3109 result before representation encoding.
Instances For
Project one exact-rational closed value and return its descriptor-width code.
Instances For
Project an exact rational, infinity, or exceptional observation into a P3109 descriptor.
Finite values are rounded once from their exact numerator and denominator. No intermediate binary or host floating-point format is involved.
Instances For
Project one finite exact rational into a P3109 descriptor.