This is an automatically generated file.
Part 1
Part 2
def standardize_fractional_precision(ulp, b):
"""Return the precision standardized so that any fraction part
is in units of 1/240. The factors of 240 = 3*5*16 ensures
that fractional octal, decimal, or hex digits will be handled
properly.
Args:
ulp: unit in the last place of a value just less than 1
b: radix
Returns:
sss
"""
Part 3
# Intuitively, ulp = b**(-precisioon), so the negative of the
# ratio of the logs retrieves the precision. But there may be
# extra bits in octal or hex or even decimal, making up a partial
# lowest-order digit. The factor 240 is a multiple of 8, 10, and
# 16 with a bit extra. The value y rounds off noise from the logs.
# TODO: resolve the apparent redundancy between the big factor 240
# and the check for being with a quarter.
x = - TWOFORTY * log(ulp) / log(b)
y = floor(ONE_HALF + x)
if (fabs(x - y) * FOUR < ONE):
x = y
p = x / TWOFORTY
y = floor(ONE_HALF + p)
if (fabs(p - y) * TWOFORTY < ONE_HALF):
p = y
return p
Part 4