MCPcopy Index your code
hub / github.com/python/cpython / conv_tables

Function conv_tables

Tools/scripts/long_conv_tables.py:22–56  ·  view source on GitHub ↗
(long_bits)

Source from the content-addressed store, hash-verified

20
21
22def conv_tables(long_bits):
23 PyLong_BASE = 1 << long_bits
24 log_base_BASE = [0.0] * 37
25 convmultmax_base = [0] * 37
26 convwidth_base = [0] * 37
27 for base in range(2, 37):
28 is_binary_base = (base & (base - 1)) == 0
29 if is_binary_base:
30 continue # don't need, leave as zero
31 convmax = base
32 i = 1
33 log_base_BASE[base] = math.log(base) / math.log(PyLong_BASE)
34 while True:
35 next = convmax * base
36 if next > PyLong_BASE:
37 break
38 convmax = next
39 i += 1
40 convmultmax_base[base] = convmax
41 assert i > 0
42 convwidth_base[base] = i
43 return '\n'.join(
44 [
45 format_array(
46 'static const double log_base_BASE[37]', log_base_BASE
47 ),
48 format_array(
49 'static const int convwidth_base[37]', convwidth_base
50 ),
51 format_array(
52 'static const twodigits convmultmax_base[37]',
53 convmultmax_base,
54 ),
55 ]
56 )
57
58
59def main():

Callers 1

mainFunction · 0.85

Calls 3

format_arrayFunction · 0.85
logMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…