11.001001000011111101101010100010001000 Arithmazium
Home

Zero and one

Paranoia's very first tests are sanity checks of \(0\) and \(1\). Function test_cond() appears throughout the code to process Yes/No tests.

milestone = 7  # ==============================
# Basic 880-950
print("Program is now RUNNING tests on small integers:")
test_cond(err_failure, (ZERO + ZERO == ZERO)
          and (ONE - ONE == ZERO)
          and (ONE > ZERO)
          and (ONE + ONE == TWO),
          "0+0 != 0, 1-1 != 0, 1 <= 0, or 1+1 != 2")

Finally, check that \(-0 = 0\). If not, call does_tiny_value_misbehave(), a test we'll see later in the exploration of underflow. Paranoia's use of global constants pokes through here. ULP_OF_ONE_PLUS and B get artificial values that pertain just to this function call.

z = -ZERO
if (z != 0.0):
    error_count[err_failure] += 1
    print("Comparison alleges that Minus Zero, obtained by setting")
    print("         X = 0  and then  Z = -X ,  is nonzero!")
    # The next two lines artificially set two global constants for the test.
    ULP_OF_ONE_PLUS = 0.001
    B = 1
    discard = does_tiny_value_misbehave(z)

We'll compute proper values for the global constants after some more tests of integer values.

Home