P3109 square-root rounding by exact square comparisons #
For a nonnegative rational radicand, the floor candidate is sqrt (numerator / denominator)
computed in natural numbers. Rounding compares the radicand with the square of an exact rational
threshold. This decides rounding of the square root even when it is irrational.
Stochastic A and B select the upper candidate at their supplied random threshold. Stochastic C uses the half-integer threshold of its nearest-even integer rounding, including its tie parity. The random word is an explicit input, as in §4.7.4 of the P3109 4.0.3 working-group report.
Square root, reciprocal square root, and hypotenuse follow §§4.10.8 and 4.10.14 of that unapproved report. Each evaluates its exact radicand before the one rounding and saturation step.
Floor of the nonnegative square root of numerator / denominator.
Instances For
Compare sqrt (numerator / denominator) with threshold / scale by squaring.
The denominator and threshold scale are positive at every arithmetic call site.
Instances For
Select the upper candidate from exact threshold comparisons.
For stochastic A and B the threshold is the first fraction whose scaled floor reaches the required integer. For C it is the midpoint below that integer, with the integer's tie parity. The comparison argument permits the executable square comparisons and real semantics to share these policy rules.
Instances For
The executable square-root boundary test for one report rounding mode.
Instances For
The report's quantum for the square root of a positive rational.
Instances For
Round the exact nonnegative square root to the descriptor's precision.
The integer division of the radicand's binary exponent by two is floor division, including
negative exponents. The scaled numerator and denominator represent the square of the significand,
so the scaling exponent is -2 * quantum.
Square-root callers establish that the radicand is nonnegative. On an arbitrary rational this precision helper rounds the square root of its absolute value.
Instances For
Square root in the closed domain, with precision rounding before saturation.
Instances For
Apply the report saturation policy after square-root precision rounding.
Instances For
Encode the already rounded and saturated square-root datum.
Instances For
Exact radicand for reciprocal square root, retaining its distinct nonpositive domain.
Instances For
Exact sum of squares for hypotenuse; either NaN takes precedence over infinity.
Instances For
Project the exact square root of a closed rational datum.
Instances For
Square root into an independent destination; negative inputs produce NaN.
Instances For
Reciprocal square root with one final projection; nonpositive finite inputs produce NaN.
Instances For
Hypotenuse from the exact sum of squares, with no intermediate overflow or rounding.
Instances For
Same-format square root, rounding the exact real value.
Instances For
Same-format reciprocal square root, rounding the exact real value.
Instances For
Same-format hypotenuse with one final projection of the exact norm.