From fe4855be9cd7dc5070a6a484ee31a47b2a6b67c1 Mon Sep 17 00:00:00 2001 From: Luke Kenneth Casson Leighton Date: Mon, 29 Apr 2019 20:54:30 +0100 Subject: [PATCH] extra tests to find out rounding conditions --- src/add/fsqrt.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/add/fsqrt.py b/src/add/fsqrt.py index 2171646c..9b4c32dc 100644 --- a/src/add/fsqrt.py +++ b/src/add/fsqrt.py @@ -97,13 +97,16 @@ def fsqrt_test(x): print("x decode", s, e, m, hex(m)) m |= 1<<23 # set top bit (the missing "1" from mantissa) - m <<= 25 + m <<= 27 sm, se = main(m, e) - sm >>= 1 + lowbits = sm & 0x3 + sm >>= 2 sm = get_mantissa(sm) #sm += 2 - print("our sqrt", s, se, sm, hex(sm), bin(sm)) + print("our sqrt", s, se, sm, hex(sm), bin(sm), "lowbits", lowbits) + if lowbits >= 2: + print ("probably needs rounding (+1 on mantissa)") sq_xbits = sq_test.bits s, e, m = decode_fp32(sq_xbits) @@ -134,6 +137,10 @@ if __name__ == '__main__': fsqrt_test(x) x = Float32(8.5) fsqrt_test(x) + x = Float32(3.14159265358979323) + fsqrt_test(x) + x = Float32(12.99392923123123) + fsqrt_test(x) """ -- 2.30.2