11.001001000011111101101010100010001000 Arithmazium
Home

Case 4

Paranoia in Python skips the cases and tests the values directly. Case 4 includes IEEE 754 arithmetic. In the elaborate compound test below, add_sub_hi is the value below which precision degrades, so it must match the computed underflow_threshold. Similarly, the tiniest difference should match the smallest nonzero value detected. The key to the third expression is the ratio add_sub_tiny / SAFE_ULPS_OF_ONE, which should match underflow_threshold.

[QUESTION: Why isn’t that test for zero? Is this just a “tiny enough” idiom, which is safer than testing for true zero?]

if add_sub_tiny and underflow_threshold:
    # BASIC case 4
    if ((add_sub_hi == underflow_threshold) and (add_sub_tiny == min_positive)
            and (fabs(underflow_threshold - add_sub_tiny / SAFE_ULPS_OF_ONE)
                 <= add_sub_tiny)):
        flags["IEEE"] = is_gradual_underflow_IEEE(min_positive)
Home