Shared arithmetic for fixed-width square-root refinements #
The binary32, binary64, and binary128 square-root kernels use the same affine exponent calculation with different format constants. This module records that calculation once so each backend proof only supplies its descriptor-specific constants.
The unpacked-model accuracy used by integer square root rounds up exactly when the square remainder is larger than the lower root.
For n = root² + remainder, comparison with (root + 1/2)² reduces to comparing the integer
remainder with root: remainder ≤ root is below the midpoint, while the next integer remainder
is above it. Thus an integer radicand cannot produce a square-root midpoint tie.
Move an even affine offset through Euclidean division by two.
The balance equation says that inputShift and outputOffset describe the same exponent origin
on opposite sides of the radix point.
Normalize the total-exponent numerator used by square-root target-exponent calculations.
Normalize the target exponent selected for a square-root result.
The hypotheses express the format-independent relationships among the encoded exponent origin, the result bias, and the fraction width. In particular, the affine offset must leave enough room for the normalized result significand, and the input leading bit must lie within that significand.
Compute the nonnegative integer shift required to align a square-root radicand.
After the exponent origins cancel, only the parity of the affine position remains. The result is therefore twice the destination fraction width, minus the input's leading-bit position, plus one when the affine position is odd.
Express the square-root shift directly in terms of the input position when the affine offset is even.
Express the square-root shift directly in terms of the input position when the affine offset is odd.