From aa8c754e7d66345a67faa0804e97f38612b283c1 Mon Sep 17 00:00:00 2001 From: Luke Kenneth Casson Leighton Date: Tue, 30 Apr 2019 21:54:18 +0100 Subject: [PATCH] move normalise function, add lowbits param, call it --- src/add/fsqrt.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) 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 - """ -- 2.30.2