From 2a273381d3f843cd58b99cbc45728761a4d12d0d Mon Sep 17 00:00:00 2001 From: Aleksandar Kostovic Date: Mon, 6 May 2019 15:47:01 +0200 Subject: [PATCH] Added secial cases for normalization function --- src/ieee754/fpsqrt/fsqrt.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/ieee754/fpsqrt/fsqrt.py b/src/ieee754/fpsqrt/fsqrt.py index 02449b0f..15f1555d 100644 --- a/src/ieee754/fpsqrt/fsqrt.py +++ b/src/ieee754/fpsqrt/fsqrt.py @@ -86,6 +86,18 @@ def normalise(s, m, e, lowbits): 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 -- 2.30.2