P3109 projection #
P3109 projection has three distinct steps:
- round finite dyadics to the descriptor's precision, preserve infinities, and map exceptions to NaN;
- apply the selected saturation rule at the descriptor's finite endpoints;
- encode the resulting datum.
This module follows that order directly. All integer widths, exponent bounds, and special codes
come from Format; there are no named-width branches or host floating-point conversions.
The stochastic modes receive a caller-supplied BitVec, whose width enforces the random-word
range.
Reference #
- IEEE Working Group P3109, Interim Report on Arithmetic Formats for Machine Learning,
version 4.0.3 (1 September 2026), Sections 4.7.3--4.7.6, repository revision
34f5964, https://github.com/P3109/Public/tree/34f5964d9bb2382b2665d15467fc3517b990b308.
Instances For
Construct a supplied random word from the low width bits of a natural number.
Instances For
Read the supplied random bits as an unsigned natural number.
Instances For
Rounding modes defined by P3109 Section 4.7.4.
- towardZero : RoundingMode
- towardPositive : RoundingMode
- towardNegative : RoundingMode
- nearestTiesToAway : RoundingMode
- nearestTiesToEven : RoundingMode
- toOdd : RoundingMode
- stochasticA (random : RandomBits) : RoundingMode
- stochasticB (random : RandomBits) : RoundingMode
- stochasticC (random : RandomBits) : RoundingMode
Instances For
Instances For
Saturation modes defined by P3109 Section 4.7.5.
- finite : SaturationMode
- propagate : SaturationMode
- none : SaturationMode
Instances For
Instances For
Complete policy used by one P3109 projection.
- rounding : RoundingMode
Rule used when precision rounding discards nonzero low bits.
- saturation : SaturationMode
Rule used after rounding produces a value outside the target datum set.
Instances For
Instances For
FloatLib default projection: nearest-even rounding and no finite saturation request.
Instances For
Nearest-even projection clamped to the finite range.
Instances For
Largest finite positive code point for this descriptor.
Instances For
Exact largest finite value in this descriptor.
Instances For
Exact smallest finite value in this descriptor.
Instances For
Whether the lower candidate has an even P3109 code at a rounding boundary.
For P > 1, code parity is ordinary significand parity. The P = 1 branch is the special rule
from Section 4.7.4: zero is even, and a nonzero code is even exactly when Q + B is even.
Instances For
Floor of (remainder / 2^discardedBits) * 2^outputBits.
Instances For
Nearest-even integer to (remainder / 2^discardedBits) * 2^outputBits.
Instances For
Decide whether precision rounding selects the integer above the floor candidate.
Instances For
Round one exact finite dyadic to P3109 precision before saturation.
The quantum is
max(floor(log2 |X|), 1 - B) - P + 1, so the same implementation handles normals,
subnormals, P = 1, and arbitrary descriptor widths.
Instances For
Apply P3109 precision rounding while preserving infinities and mapping exceptions to NaN.
Instances For
Saturate a rounded value below the finite range.
Instances For
Saturate a rounded value above the finite range.
Instances For
Apply P3109 Section 4.7.5 to a value that has already been rounded to precision.
Instances For
Mathematical result of P3109 projection before representation encoding.
Precision rounding is followed by saturation. The result gives the datum meaning before encoding.
Instances For
Encode a positive finite datum.
The caller supplies a value already rounded to precision and inside the finite range. This is the integer form of Section 4.7.6; it does not enumerate the codebook.
Instances For
Encode a value known to be in this descriptor's datum set.
Instances For
P3109 equality of datum meanings.
Finite values are equal numerically, infinity signs must match, and every NaN payload denotes the format's single NaN datum. Other exceptional categories are not P3109 datums.
Instances For
Executable equality of P3109 datum meanings.
Finite dyadics are compared numerically, so harmless differences in significand normalization do not make a representable value fail the checked encoder. P3109 has one NaN, so its optional payload is not semantically observable here.
Instances For
Encode a value only when it belongs to this descriptor's datum set.
Unlike projection, this operation performs no rounding or saturation. It computes the direct P3109 code, decodes it, and accepts the result only when the numerical datum is unchanged.
Instances For
Project one exact closed value and return its descriptor-width code.
Instances For
Project an exact finite, infinite, or NaN value into a P3109 descriptor.
The operation rounds once to P3109 precision, applies saturation, and encodes the result directly. It never routes through IEEE 754 or a host float.
Instances For
Project one exact finite dyadic into a P3109 descriptor.
Instances For
Encode an already representable P3109 datum without rounding it.