From d52e3059bde94a00522ffbc63bc7451a6e737932 Mon Sep 17 00:00:00 2001 From: Daniel Lemire Date: Wed, 13 Jan 2021 09:17:53 -0500 Subject: [PATCH] Update table_generation.py --- script/table_generation.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/script/table_generation.py b/script/table_generation.py index f94f437..24fec7c 100644 --- a/script/table_generation.py +++ b/script/table_generation.py @@ -1,10 +1,4 @@ def format(number): - # move the most significant bit in position - while(number < (1<<127)): - number *= 2 - # then *truncate* - while(number >= (1<<128)): - number //= 2 upper = number // (1<<64) lower = number % (1<<64) print(""+hex(upper)+","+hex(lower)+",") @@ -14,16 +8,24 @@ for q in range(-342,0): z = 0 while( (1<= -17 ): + if(q >= -27): b = z + 127 c = 2 ** b // power5 + 1 - assert c < (1<<128) format(c) else: b = 2 * z + 2 * 64 c = 2 ** b // power5 + 1 + # truncate + while(c >= (1<<128)): + c //= 2 format(c) for q in range(0,308+1): power5 = 5 ** q + # move the most significant bit in position + while(power5 < (1<<127)): + power5 *= 2 + # *truncate* + while(power5 >= (1<<128)): + power5 //= 2 format(power5)