11.001001000011111101101010100010001000 Arithmazium
Home

compute_safe_ulps_of_one()

Find a small value \( \epsilon \) such that \( (1 + \epsilon) \times C > 1 \), where \( C \) is a tiny power of the radix, not too near the underflow threshold.

The issue is not tininess, but rather whether \( \epsilon \) is lost due to deficiencies in multiplication, such as the lack of a guard digit. Refer to the function does_mult_have_guard_digit() for elaboration on the guard digit issue.

def compute_safe_ulps_of_one():
    """Return a value useful in underflow and square root testing.

    Given the constant C, a power of B not far above the underflow
    threshold, find x such that (1+x)*C > C. Try x = 1 ulp,
    but back off to B ulps of one. C is large enough that
    underflow is not an issue, but if multiplication
    lacks a guard digit, a single ulp might be lost.

    Returns:
        1 or B ulps of one

    Basic: 4450-4460
    """

If the fallback value of B ulps of one still doesn't leave a nonzero low-order residue, that fact will be caught down the road.

    x = ULP_OF_ONE_PLUS
    s = ONE + x
    d = C * s
    if d <= C:
        # Fall back to B digits. A later test determines
        # whether multiplication is just too awful.
        x = B * ULP_OF_ONE_PLUS
    return x


Home