From: Luke Kenneth Casson Leighton Date: Mon, 29 Apr 2019 09:28:53 +0000 (+0100) Subject: decode xbits (an integer) not x (an object) X-Git-Tag: ls180-24jan2020~1119 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=8139ce104fc86618e4dfd293e9156a042bce4dda;p=ieee754fpu.git decode xbits (an integer) not x (an object) --- diff --git a/src/add/fsqrt.py b/src/add/fsqrt.py index da3819c1..ad9f432e 100644 --- a/src/add/fsqrt.py +++ b/src/add/fsqrt.py @@ -28,20 +28,20 @@ def sqrt(num): for i in range(15, -1, -1): # negative ranges are weird... if (R>=0): - + R = (R<<2)|((D>>(i+i))&3) R = R-((Q<<2)|1) #/*-Q01*/ - + else: R = (R<<2)|((D>>(i+i))&3) R = R+((Q<<2)|3) #/*+Q11*/ - + if (R>=0): Q = (Q<<1)|1 #/*new Q:*/ else: Q = (Q<<1)|0 #/*new Q:*/ - + if (R<0): R = R+((Q<<1)|1) @@ -99,13 +99,14 @@ if __name__ == '__main__': ms, es = main(m, e) print("m:%d e:%d sqrt: m:%d e:%d" % (m, e, ms, es)) + x = Float32(1234.123456789) + xbits = x.bits + print (x, type(x)) + print (xbits, type(xbits)) + s, e, m = decode_fp32(xbits) + print(s, e, m, hex(m)) -x = Float32(1234.123456789) -xbits = x.bits - - -print(decode_fp32(x)) """ Notes: