From 4063cf218f3648f3f2cfea0a86fa56199c017fb2 Mon Sep 17 00:00:00 2001 From: Christoph Conrads Date: Tue, 26 Mar 2019 16:16:39 +0100 Subject: [PATCH] Print only integer powers period length Display `2^234` instead of `2^234.56` and so on. --- compute-awc-swb-period-length.py | 13 +++++-------- find-awc-swb-prngs.sh | 2 +- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/compute-awc-swb-period-length.py b/compute-awc-swb-period-length.py index f742448..ab9454c 100644 --- a/compute-awc-swb-period-length.py +++ b/compute-awc-swb-period-length.py @@ -246,8 +246,6 @@ def main(): sys.exit(3) m = compute_modulus(b, r, s) - - #print('b=2^{:d} r={:d} s={:d}'.format(w, r, s)) key = (kind, w, r, s) ps = \ @@ -260,8 +258,6 @@ def main(): ps_awc_32_29_17 if kind=='awc' and w== 32 and r == 29 and s == 17 else \ factorize(kind, w, r, s, m-1) - #print('Found {:d} prime factors'.format(len(ps))) - assert ps is None or (m-1) % reduce(operator.mul, ps, 1) == 0 min_period, max_period = \ @@ -271,11 +267,12 @@ def main(): p2_min = math.log(min_period) / math.log(2) p2_max = math.log(max_period) / math.log(2) + floor = lambda x: int(math.floor(x)) + + msg = '{:4d} {:4d} {:3d} {:3d}' + out = msg.format(floor(p2_min),floor(p2_max),floor(p10_min),floor(p10_max)) - #print('Period length 2^{:.2f} 2^{:.2f}'.format(p2_min, p2_max)) - #print('Period length 10^{:.2f} 10^{:.2f}'.format(p10_min, p10_max)) - msg = '{:7.2f} {:7.2f} {:6.2f} {:6.2f}' - print(msg.format(p2_min, p2_max, p10_min, p10_max)) + print(out) if __name__ == '__main__': diff --git a/find-awc-swb-prngs.sh b/find-awc-swb-prngs.sh index d2cf71e..a43a8e2 100644 --- a/find-awc-swb-prngs.sh +++ b/find-awc-swb-prngs.sh @@ -166,7 +166,7 @@ find_awc_swb_prngs() echo "Found \$num_generators \$type parameter combinations" - echo 'type b r s t log2period log10period' + echo 'type b r s t log2period log10period' while read gen do local b="\$(awk '{print \$2}' <<<"\$gen")" -- 2.22.0