Executable bounded fixed-point operations #
Bounded fixed point stores an exact signed coefficient in a fixed-width two's-complement carrier. Wrapping, checked, and saturating conversions and operations have distinct names.
Multiplication also exposes the composed input scale and chosen destination width in its result type. This makes the numerical policy visible at the call site while the implementation reuses the generic fixed-integer kernels and their refinement theorems.
Wrap a complete bounded fixed-point code without conversion.
Instances For
Recover the complete bounded fixed-point code without conversion.
Instances For
Construct a bounded fixed-point value from its complete unsigned word.
Instances For
Read the complete bounded fixed-point word as an unsigned natural number.
Instances For
Encode an integer coefficient modulo 2 ^ width.
Instances For
Round an exact rational to the nearest coefficient, ties to even, then wrap it modulo
2 ^ width.
Instances For
Round an exact rational to the nearest coefficient, ties to even, and return it only when that coefficient fits the destination width.
Instances For
Round an exact rational to the nearest coefficient, ties to even, then clamp it to the signed destination range.
Instances For
Recover the stored signed integer coefficient.
Instances For
Decode a bounded fixed-point value to its exact rational meaning.
Instances For
Same-scale addition modulo 2 ^ width.
Instances For
Same-scale subtraction modulo 2 ^ width.
Instances For
Multiplication modulo 2^outWidth, with exact scale composition.
Instances For
Return the exact same-scale sum when its coefficient fits.
Instances For
Return the exact same-scale difference when its coefficient fits.
Instances For
Return the exact product when its coefficient fits the destination width.
Instances For
Same-scale addition clamped to the signed coefficient bounds.
Instances For
Same-scale subtraction clamped to the signed coefficient bounds.
Instances For
Product clamped to the signed destination range, with exact scale composition.