Lines Matching refs:base
8 The base two exponents can be inferred using a logarithmic slope
36 def calculate_bitshift(base, exponent):
38 Calculate the bitshift required for a given base. The exponent
42 return 63 + math.ceil(math.log2(base**exponent))
45 def next_fp(fp, base, step = 1):
48 return (fp[0] * (base**step), fp[1])
51 def prev_fp(fp, base, step = 1):
54 return (fp[0] // (base**step), fp[1])
65 def generate_small(base, count):
66 '''Generate the small powers for a given base'''
68 bitshift = calculate_bitshift(base, count)
73 fp = next_fp(fp, base)
76 ints = [base**i for _, i in fps]
81 def generate_large(base, step):
82 '''Generate the large powers for a given base.'''
85 min_exp = math.floor(math.log(5e-324, base) - math.log(0xFFFFFFFFFFFFFFFF, base))
86 max_exp = math.ceil(math.log(1.7976931348623157e+308, base))
87 bitshift = calculate_bitshift(base, abs(min_exp - step))
95 fp = prev_fp(fp, base, step)
102 fp = next_fp(fp, base, step)
109 def print_array(base, string, fps, index):
112 print(string.format(base, len(fps)))
115 exp = EXP_STR.format(base, exp)
120 def generate_base(base):
123 step = math.floor(math.log(1e10, base))
124 small, ints = generate_small(base, step)
125 large, bias = generate_large(base, step)
127 print_array(base, SMALL_MANTISSA_STR, small, 0)
128 print_array(base, SMALL_EXPONENT_STR, small, 1)
129 print_array(base, LARGE_MANTISSA_STR, large, 0)
130 print_array(base, LARGE_EXPONENT_STR, large, 1)
131 print(SMALL_INT_STR.format(base, len(ints), ints))
132 print(STEP_STR.format(base, step))
133 print(BIAS_STR.format(base, bias))