Real stochastic rounding thresholds #
The report's floor and nearest-even formulas can be tested by comparing the exact real fraction with one rational threshold. These identities apply to irrational fractions as well. They justify the integer square comparisons used when rounding a square root.
Reference: P3109 unapproved interim report 4.0.3, revision 34f5964, §4.7.4.
Nearest integer to a nonnegative real, with ties sent to the even integer.
Instances For
@[simp]
The real RNITE formula preserves natural numbers.
theorem
FloatLib.Floats.Formats.P3109.RealRounding.le_nearestEven_iff
(value : ℝ)
(boundary : ℕ)
(_hb : 0 < boundary)
(hv : 0 ≤ value)
:
Reaching a positive integer by nearest-even rounding is decided at its lower halfway point. At that point it is the parity of the upper integer that decides the tie.