From: Aleksandar Kostovic Date: Mon, 6 May 2019 13:47:01 +0000 (+0200) Subject: Added secial cases for normalization function X-Git-Tag: ls180-24jan2020~1012 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=2a273381d3f843cd58b99cbc45728761a4d12d0d;p=ieee754fpu.git Added secial cases for normalization function --- 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