From 5d04b89086507f1211a9988bae9d3f5d06840d66 Mon Sep 17 00:00:00 2001 From: Luke Kenneth Casson Leighton Date: Mon, 29 Apr 2019 14:42:57 +0100 Subject: [PATCH] hmmm... experimenting... --- src/add/fsqrt.py | 37 ++++++++++++++++++++++++------------- 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/src/add/fsqrt.py b/src/add/fsqrt.py index 5aaec4c3..4c6d07c6 100644 --- a/src/add/fsqrt.py +++ b/src/add/fsqrt.py @@ -85,6 +85,27 @@ def main(mantissa, exponent): return sqrt(mantissa), (exponent >> 1) +def fsqrt_test(x): + + xbits = x.bits + print ("x", x, type(x)) + sq_test = x.sqrt() + print ("sqrt", sq_test) + + print (xbits, type(xbits)) + s, e, m = decode_fp32(xbits) + print("x decode", s, e, m, hex(m)) + + #m |= 1<<23 + + sm, se = main(m, e) + print("our sqrt", s, se, sm, hex(sm), bin(sm)) + + sq_xbits = sq_test.bits + s, e, m = decode_fp32(sq_xbits) + print ("sf32 sqrt", s, e, m, hex(m), bin(m)) + print () + if __name__ == '__main__': # quick test up to 1000 of two sqrt functions @@ -100,20 +121,10 @@ if __name__ == '__main__': print("m:%d e:%d sqrt: m:%d e:%d" % (m, e, ms, es)) x = Float32(1234.123456789) - xbits = x.bits - - print (x, type(x)) - print (xbits, type(xbits)) - s, e, m = decode_fp32(xbits) - print(s, e, m, hex(m)) + fsqrt_test(x) + x = Float32(8.0) + fsqrt_test(x) - se, sm = main(e, m) - print("our sqrt", s, se, sm, hex(sm), bin(sm)) - - sq_test = x.sqrt() - sq_xbits = sq_test.bits - s, e, m = decode_fp32(sq_xbits) - print ("sf32 sqrt", s, e, m, hex(m), bin(m)) """ Notes: -- 2.30.2