X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fadd%2Ffsqrt.py;h=02449b0f75b41b0ba2e004711d9570ccca49ca3d;hb=aa8c754e7d66345a67faa0804e97f38612b283c1;hp=e0696ebcdbdce37e8df41f9dec58b42f620b5036;hpb=c9c4ee1bf227367ead272e79adda7d265aaaba35;p=ieee754fpu.git diff --git a/src/add/fsqrt.py b/src/add/fsqrt.py index e0696ebc..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: @@ -140,6 +152,9 @@ if __name__ == '__main__': x = Float32(0.123456) fsqrt_test(x) + + + """ Notes: