projects
/
ieee754fpu.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
a2ec0df
)
add some functions copied from unit_test_single for mantissa/exponent handling
author
Luke Kenneth Casson Leighton
<lkcl@lkcl.net>
Sun, 28 Apr 2019 13:44:49 +0000
(14:44 +0100)
committer
Luke Kenneth Casson Leighton
<lkcl@lkcl.net>
Sun, 28 Apr 2019 13:44:49 +0000
(14:44 +0100)
src/add/fsqrt.py
patch
|
blob
|
history
diff --git
a/src/add/fsqrt.py
b/src/add/fsqrt.py
index 3a8f8905680e5a94d52466a157239f1944dd63f5..728503148f0b175a2c60becfa33fb50e9b18354b 100644
(file)
--- a/
src/add/fsqrt.py
+++ b/
src/add/fsqrt.py
@@
-45,6
+45,21
@@
def sqrt(num):
return Q
+# grabbed these from unit_test_single (convenience, this is just experimenting)
+
+def get_mantissa(x):
+ return 0x7fffff & x
+
+def get_exponent(x):
+ return ((x & 0x7f800000) >> 23) - 127
+
+def set_exponent(x, e):
+ return (x & ~0x7f800000) | ((e+127) << 23)
+
+def get_sign(x):
+ return ((x & 0x80000000) >> 31)
+
+
def main(mantissa, exponent):
if exponent & 1 != 0:
return sqrt(mantissa << 1), # shift mantissa up