From: Luke Kenneth Casson Leighton Date: Mon, 29 Apr 2019 14:12:19 +0000 (+0100) Subject: guessing / experimenting... X-Git-Tag: ls180-24jan2020~1114 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=727a7abda2212ea1fabf0b68b37b903154fd00ee;p=ieee754fpu.git guessing / experimenting... --- diff --git a/src/add/fsqrt.py b/src/add/fsqrt.py index 4c6d07c6..3b6d1f23 100644 --- a/src/add/fsqrt.py +++ b/src/add/fsqrt.py @@ -25,7 +25,7 @@ def sqrt(num): Q = 0 R = 0 r = 0 # remainder - for i in range(15, -1, -1): # negative ranges are weird... + for i in range(64, -1, -1): # negative ranges are weird... if (R>=0): @@ -96,9 +96,13 @@ def fsqrt_test(x): s, e, m = decode_fp32(xbits) print("x decode", s, e, m, hex(m)) - #m |= 1<<23 + m |= 1<<24 # set top bit (the missing "1" from mantissa) + m <<= 24 sm, se = main(m, e) + sm >>= 1 + sm = get_mantissa(sm) + #sm += 2 print("our sqrt", s, se, sm, hex(sm), bin(sm)) sq_xbits = sq_test.bits @@ -122,8 +126,14 @@ if __name__ == '__main__': x = Float32(1234.123456789) fsqrt_test(x) + x = Float32(32.1) + fsqrt_test(x) + x = Float32(16.0) + fsqrt_test(x) x = Float32(8.0) fsqrt_test(x) + x = Float32(8.5) + fsqrt_test(x) """