mirror of
https://github.com/fastfloat/fast_float.git
synced 2025-12-07 01:06:48 +08:00
* fixed version updates in release script * formatted Python scripts with `black` - The uncompromising code formatter (https://black.readthedocs.io/) * f-string all the things
39 lines
715 B
Python
39 lines
715 B
Python
import sys
|
|
from math import floor
|
|
|
|
|
|
def log2(x):
|
|
"""returns ceil(log2(x)))"""
|
|
y = 0
|
|
while (1 << y) < x:
|
|
y = y + 1
|
|
return y
|
|
|
|
|
|
for q in range(1, 17 + 1):
|
|
d = 5 ** q
|
|
b = 127 + log2(d)
|
|
t = 2 ** b
|
|
c = t // d + 1
|
|
assert c < 2 ** 128
|
|
assert c >= 2 ** 127
|
|
K = 2 ** 127
|
|
if not (c * K * d <= (K + 1) * t):
|
|
print(q)
|
|
top = floor(t / (c * d - t))
|
|
sys.exit(-1)
|
|
|
|
for q in range(18, 344 + 1):
|
|
d = 5 ** q
|
|
b = 64 + 2 * log2(d)
|
|
t = 2 ** b
|
|
c = t // d + 1
|
|
assert c > 2 ** (64 + log2(d))
|
|
K = 2 ** 64
|
|
if not (c * K * d <= (K + 1) * t):
|
|
print(q)
|
|
top = floor(t / (c * d - t))
|
|
sys.exit(-1)
|
|
|
|
print("all good")
|