This is an automatically generated file.
Part 1
Part 2
def how_does_add_sub_round():
"""Check rounding on add/subtract.
Returns:
"rounded", "chopped", "other"
"""
Part 3
round_add_sub = "other"
x = ONE - ULP_OF_ONE_MINUS * ULP_OF_ONE_MINUS
y = ONE + ULP_OF_ONE_PLUS * (ONE - ULP_OF_ONE_PLUS)
z = ONE_MINUS_ULP - ONE_HALF
x = (x - ONE_HALF) - z
y = y - ONE
Part 4
if (x == ZERO) and (y == ZERO):
round_add_sub = "chopped"
print("Add/Subtract appears to be chopped. ")
Part 5
while flags["add_sub_guard_digit"]: # JTC TODO jibe with Basic
x = (ONE_HALF + ULP_OF_ONE_PLUS) * ULP_OF_ONE_PLUS
y = (ONE_HALF - ULP_OF_ONE_PLUS) * ULP_OF_ONE_PLUS
x = ONE + x
y = ONE + y
x = (ONE + ULP_OF_ONE_PLUS) - x
y = ONE - y
if x != ZERO or y != ZERO: break
Part 6
x = (ONE_HALF + ULP_OF_ONE_PLUS) * ULP_OF_ONE_MINUS
y = (ONE_HALF - ULP_OF_ONE_PLUS) * ULP_OF_ONE_MINUS
x = ONE - x
y = ONE - y
x = ONE_MINUS_ULP - x
y = ONE - y
if x != ZERO or y != ZERO: break
Part 7
if round_add_sub == "chopped":
# ***JTC: BASIC 2690 sets R3 = F1 - O2*R3 triggering 3
# messages when boch chopped and rounded are detected.
round_add_sub = "other"
else:
round_add_sub = "rounded"
print("Addition/Subtraction appears to round correctly. ")
Part 8
if not flags["add_sub_guard_digit"]:
# ***JTC: BUG, annot happen, guard digit is checked above.
notify("Add/Subtract")
break # Execute this block just once, with early exit possible.
Part 9
if round_add_sub == "other": # pick up all the odd cases
print("Addition/Subtraction neither rounds nor chops.")
return round_add_sub
Part 10