projects
/
ieee754fpu.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
ae8378b
)
add some comments to fsqrt
author
Luke Kenneth Casson Leighton
<lkcl@lkcl.net>
Tue, 7 May 2019 00:24:45 +0000
(
01:24
+0100)
committer
Luke Kenneth Casson Leighton
<lkcl@lkcl.net>
Tue, 7 May 2019 00:24:45 +0000
(
01:24
+0100)
src/ieee754/fpsqrt/fsqrt.py
patch
|
blob
|
history
diff --git
a/src/ieee754/fpsqrt/fsqrt.py
b/src/ieee754/fpsqrt/fsqrt.py
index 15f1555d969098246dc9df4bf1f3ffce812d6958..5ae2bb253fa1356ec89f2960930b884faf51a2db 100644
(file)
--- a/
src/ieee754/fpsqrt/fsqrt.py
+++ b/
src/ieee754/fpsqrt/fsqrt.py
@@
-86,17
+86,23
@@
def normalise(s, m, e, lowbits):
m += 1
if get_mantissa(m) == ((1<<24)-1):
e += 1
m += 1
if get_mantissa(m) == ((1<<24)-1):
e += 1
- #if the num is NaN, than adjust
+
+ # this is 2nd-stage normalisation. can move it to a separate fn.
+
+ #if the num is NaN, then adjust (normalised NaN rather than de-normed NaN)
if (e == 128 & m !=0):
if (e == 128 & m !=0):
- z[31] = 1
- z[30:23] = 255
- z[22] = 1
- z[21:0] = 0
- #if the num is Inf, then adjust
+ # these are in IEEE754 format, this function returns s,e,m not z
+ z[31] = 1 # sign (so, s=1)
+ z[30:23] = 255 # exponent (minus 128, so e = 127
+ z[22] = 1 # high bit of mantissa, so m = 1<<22 i think
+ z[21:0] = 0 # rest of mantissa is zero, so m = 1<<22 is good.
+
+ #if the num is Inf, then adjust (to normalised +/-INF)
if (e == 128):
if (e == 128):
- z[31] = s
- z[30:23] = 255
- z[22:0] = 0
+ # these are in IEEE754 format, this function returns s,e,m not z
+ z[31] = s # s is already s, so do nothing to s.
+ z[30:23] = 255 # have to subtract 128, so e = 127 (again)
+ z[22:0] = 0 # mantissa... so m=0
return s, m, e
return s, m, e