From: Luke Kenneth Casson Leighton Date: Mon, 29 Apr 2019 19:54:30 +0000 (+0100) Subject: extra tests to find out rounding conditions X-Git-Tag: ls180-24jan2020~1112 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=fe4855be9cd7dc5070a6a484ee31a47b2a6b67c1;p=ieee754fpu.git extra tests to find out rounding conditions --- 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) """