From 83f502bb66c6033b932b1e1b39be7cbdbed03f09 Mon Sep 17 00:00:00 2001 From: Luke Kenneth Casson Leighton Date: Sun, 28 Apr 2019 17:56:57 +0100 Subject: [PATCH] get the sqrt m/e, print out the original m/e side-by-side with sqrt m/e --- src/add/fsqrt.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/add/fsqrt.py b/src/add/fsqrt.py index dc0922b3..d94700ff 100644 --- a/src/add/fsqrt.py +++ b/src/add/fsqrt.py @@ -83,15 +83,18 @@ def main(mantissa, exponent): if __name__ == '__main__': + + # quick test up to 1000 of two sqrt functions for Q in range(1, int(1e4)): print(Q, sqrt(Q), sqrtsimple(Q), int(Q**0.5)) assert int(Q**0.5) == sqrtsimple(Q), "Q sqrtsimpl fail %d" % Q assert int(Q**0.5) == sqrt(Q), "Q sqrt fail %d" % Q - - for e in range(25): - for m in range(25): - print(main(m, e)) + # quick mantissa/exponent demo + for e in range(26): + for m in range(26): + ms, es = main(m, e) + print("m:%d e:%d sqrt: m:%d e:%d" % (m, e, ms, es)) """ //This is the main code of integer sqrt function found here:http://verilogcodes.blogspot.com/2017/11/a-verilog-function-for-finding-square-root.html -- 2.30.2