File: analysis.py

package info (click to toggle)
fast-float 8.1.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 896 kB
  • sloc: cpp: 7,252; ansic: 3,474; python: 366; sh: 37; makefile: 9
file content (38 lines) | stat: -rw-r--r-- 715 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
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")