Signed projection guarantees #
The error bounds concern the actual rational value of the returned datum. The bounds assume that the returned overflow flag is false. Directed bounds and midpoint decisions come from the integer-grid rounder.
theorem
FloatLib.Floats.Formats.DecimalInterchange.projectMagnitude_overflow_iff
(f : Format)
(mode : RoundingMode)
(s : Bool)
(x : ℚ)
(preferred : ℤ)
:
(projectMagnitude f mode s x preferred).status.overflow = true ↔ f.maxQuantum < (roundedPair f mode s x).2
theorem
FloatLib.Floats.Formats.DecimalInterchange.projectMagnitude_error_lt_one
(f : Format)
(mode : RoundingMode)
(s : Bool)
{x : ℚ}
(hx : 0 ≤ x)
(preferred : ℤ)
(hq : (roundedPair f mode s x).2 ≤ f.maxQuantum)
:
theorem
FloatLib.Floats.Formats.DecimalInterchange.project_error_le_half
(f : Format)
(mode : RoundingMode)
(hm : mode = RoundingMode.nearestEven ∨ mode = RoundingMode.nearestAway)
(x : ℚ)
(preferred : ℤ)
(negativeZero : Bool)
(hfinite : (project f mode x preferred negativeZero).status.overflow = false)
:
Both nearest modes have at most half a unit of error on the selected decimal grid.
theorem
FloatLib.Floats.Formats.DecimalInterchange.project_error_lt_one
(f : Format)
(mode : RoundingMode)
(x : ℚ)
(preferred : ℤ)
(negativeZero : Bool)
(hfinite : (project f mode x preferred negativeZero).status.overflow = false)
:
In every rounding direction, a nonoverflowing result is less than one grid unit away.
theorem
FloatLib.Floats.Formats.DecimalInterchange.projectMagnitude_inexact_iff
(f : Format)
(mode : RoundingMode)
(s : Bool)
(x value : ℚ)
(preferred : ℤ)
(hq : (roundedPair f mode s x).2 ≤ f.maxQuantum)
(hv : (projectMagnitude f mode s x preferred).value.toRat? = some value)
:
Without overflow, the inexact flag detects a change in numerical value.
theorem
FloatLib.Floats.Formats.DecimalInterchange.project_inexact_iff
(f : Format)
(mode : RoundingMode)
(x value : ℚ)
(preferred : ℤ)
(negativeZero : Bool)
(hfinite : (project f mode x preferred negativeZero).status.overflow = false)
(hv : (project f mode x preferred negativeZero).value.toRat? = some value)
:
Without overflow, inexactness is equivalent to a change in numerical value.