From: Luke Kenneth Casson Leighton Date: Tue, 30 Apr 2019 20:54:18 +0000 (+0100) Subject: move normalise function, add lowbits param, call it X-Git-Tag: ls180-24jan2020~1093 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=aa8c754e7d66345a67faa0804e97f38612b283c1;p=ieee754fpu.git move normalise function, add lowbits param, call it --- diff --git a/src/add/fsqrt.py b/src/add/fsqrt.py index 8e116667..02449b0f 100644 --- a/src/add/fsqrt.py +++ b/src/add/fsqrt.py @@ -80,6 +80,15 @@ def main(mantissa, exponent): return m, r, exponent >> 1 +#normalization function +def normalise(s, m, e, lowbits): + if (lowbits >= 2): + m += 1 + if get_mantissa(m) == ((1<<24)-1): + e += 1 + return s, m, e + + def fsqrt_test(x): xbits = x.bits @@ -99,6 +108,9 @@ def fsqrt_test(x): sm >>= 2 sm = get_mantissa(sm) #sm += 2 + + s, sm, se = normalise(s, sm, se, lowbits) + print("our sqrt", s, se, sm, hex(sm), bin(sm), "lowbits", lowbits, "rem", hex(sr)) if lowbits >= 2: @@ -141,13 +153,6 @@ if __name__ == '__main__': fsqrt_test(x) -#normalization function -def normalise(s, m, e): - if (lowbits >= 2): - m += 1 - if get_mantissa(m) == ((1<<24)-1): - e += 1 - """