Basic posit functions #
Absolute value, sign, integer rounding, and representation successor/predecessor from Section 5.2 of the 2022 Posit Standard. Negation is defined with the model.
next and prior wrap over the complete bit vector, including NaR, as specified by the standard.
Other posit-valued functions preserve NaR. Integer rounding uses exact rational decoding,
Rat.floor or Rat.ceil, and the shared posit rounder.
References #
- Posit Working Group, Standard for Posit Arithmetic (2022), March 2, 2022, Sections 5.1--5.2, https://posithub.org/docs/posit_standard-2.pdf.
Lexicographic successor of the complete representation, wrapping modulo 2 ^ format.bits.
Unlike ordinary real-valued functions, next does not propagate NaR: it advances from the NaR
word to the following encoded word.
Instances For
Lexicographic predecessor of the complete representation, wrapping modulo 2 ^ format.bits.
As required by the standard, this is the exact inverse of next, including at zero, NaR, and the
unsigned wrap boundary.
Instances For
Standard absolute value.
The encoded order places NaR below zero, but whole-word negation fixes NaR, so this definition also has the required NaR propagation without assigning NaR a numerical sign.
Instances For
Standard sign function.
NaR is checked before encoded comparisons because NaR is the least word but has no numerical
sign. Positive and negative results are created by exact rounding of ±1.
Instances For
The shared exact nearest-even integer rounder, exposed through the posit API.
Instances For
An exact integer is unchanged by nearest-even integer rounding.
Nearest integer-valued posit, with an even-integer tie rule and NaR propagation.
Instances For
Smallest integer-valued posit greater than or equal to the input, with NaR propagation.
Instances For
Largest integer-valued posit less than or equal to the input, with NaR propagation.
Instances For
Nearest-integer rounding propagates NaR.
Nearest-integer rounding fixes the canonical zero word.