projects
/
ieee754fpu.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
d8ce060
)
extra tests to find out rounding conditions
author
Luke Kenneth Casson Leighton
<lkcl@lkcl.net>
Mon, 29 Apr 2019 19:54:30 +0000
(20:54 +0100)
committer
Luke Kenneth Casson Leighton
<lkcl@lkcl.net>
Mon, 29 Apr 2019 19:54:30 +0000
(20:54 +0100)
src/add/fsqrt.py
patch
|
blob
|
history
diff --git
a/src/add/fsqrt.py
b/src/add/fsqrt.py
index 2171646c51a54e7da9284105698ab18b84fe8349..9b4c32dc8b7413b7bf7538ab989e2c490c6ae835 100644
(file)
--- 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)
print("x decode", s, e, m, hex(m))
m |= 1<<23 # set top bit (the missing "1" from mantissa)
- m <<= 2
5
+ m <<= 2
7
sm, se = main(m, e)
sm, se = main(m, e)
- sm >>= 1
+ lowbits = sm & 0x3
+ sm >>= 2
sm = get_mantissa(sm)
#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)
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)
fsqrt_test(x)
x = Float32(8.5)
fsqrt_test(x)
+ x = Float32(3.14159265358979323)
+ fsqrt_test(x)
+ x = Float32(12.99392923123123)
+ fsqrt_test(x)
"""
"""