This is an automatically generated file.
Part 1
Part 2
def how_does_mult_round():
"""Check type of rounding in multiplication.
Returns:
"rounded", "chopped", "other"
"""
Part 3
rmult = "other"
y2 = ONE + ULP_OF_ONE_PLUS
y1 = ONE - ULP_OF_ONE_PLUS
x = ONE_AND_HALF - ULP_OF_ONE_PLUS
y = ONE_AND_HALF + ULP_OF_ONE_PLUS
z = (x - ULP_OF_ONE_PLUS) * y2
t = y * y1
z = z - x
t = t - x
Part 4
x = x * y2
y = (y + ULP_OF_ONE_PLUS) * y1
x = x - ONE_AND_HALF
y = y - ONE_AND_HALF
Part 5
if ((x == ZERO) and (y == ZERO) and (z == ZERO) and (t <= ZERO)):
x = (ONE_AND_HALF + ULP_OF_ONE_PLUS) * y2
y = ONE_AND_HALF - ULP_OF_ONE_PLUS - ULP_OF_ONE_PLUS
z = ONE_AND_HALF + ULP_OF_ONE_PLUS + ULP_OF_ONE_PLUS
t = (ONE_AND_HALF - ULP_OF_ONE_PLUS) * y1
Part 6
x = x - (z + ULP_OF_ONE_PLUS)
s1 = y * y1
s = z * y2
t = t - y
y = (ULP_OF_ONE_PLUS - y) + s1
z = s - (z + ULP_OF_ONE_PLUS + ULP_OF_ONE_PLUS)
Part 7
s1 = (y2 + ULP_OF_ONE_PLUS) * y1
y1 = y2 * y1
s1 = s1 - y2
y1 = y1 - ONE_HALF
Part 8
if ((x == ZERO) and (y == ZERO) and (z == ZERO) and (t == ZERO)
and (s1 == ZERO) and (y1 == ONE_HALF)):
rmult = "rounded"
print("Multiplication appears to round correctly. ")
Part 9
elif ((x + ULP_OF_ONE_PLUS == ZERO) and (y < ZERO) and (z + ULP_OF_ONE_PLUS == ZERO)
and (t < ZERO) and (s1 + ULP_OF_ONE_PLUS == ZERO)
and (y1 < ONE_HALF)):
rmult = "chopped"
print("Multiplication appears to chop. ")
Part 10
else:
print("* is neither chopped nor correctly rounded. ")
if (rmult == "rounded"
and not flags["mult_guard_digit"]):
notify("Multiplication")
Part 11
else:
print("* is neither chopped nor correctly rounded. ")
return rmult
Part 12