Decimal square root by exact squared comparisons #
An integer square root brackets the scaled result. Comparing the radicand with the squared midpoint decides nearest rounding exactly, including ties. All decisions use integer and rational arithmetic.
The preferred exponent is the floor of half the operand quantum (IEEE 754-2019 §5.4.1). Negative zero survives, while a negative nonzero operand raises invalid (§§6.3, 7.2).
Decimal scale shift for a square root, computed without evaluating a real square root.
Instances For
Smallest coefficient grid which fits the exact square root.
Instances For
Integer floor of a nonnegative rational's square root.
Instances For
Decide the upper adjacent integer by exact comparison with a squared midpoint.
Instances For
Round a nonnegative square root on the integer grid.
Instances For
Rounded coefficient and quantum; an exact power-of-ten carry loses no value.
Instances For
Round the square root of a nonnegative rational, selecting the preferred cohort member when the result is exact.
Instances For
Square root in all five rounding modes, including signed zeros and NaN diagnostics.