Added secial cases for normalization function
[ieee754fpu.git] / src / ieee754 / fpsqrt / fsqrt.py
index 02449b0f75b41b0ba2e004711d9570ccca49ca3d..15f1555d969098246dc9df4bf1f3ffce812d6958 100644 (file)
@@ -86,6 +86,18 @@ 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
+    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
+    if (e == 128):
+        z[31] = s
+        z[30:23] = 255
+        z[22:0] = 0
+
     return s, m, e
 
 
     return s, m, e