[libre-riscv-dev] [Bug 74] preliminary exploratory software emulation of FP SQRT
bugzilla-daemon at libre-riscv.org
bugzilla-daemon at libre-riscv.org
Sun Apr 28 18:03:59 BST 2019
http://bugs.libre-riscv.org/show_bug.cgi?id=74
--- Comment #23 from Luke Kenneth Casson Leighton <lkcl at lkcl.net> ---
(In reply to Aleksandar Kostovic from comment #21)
> fixed, on to the testing of for loop:
>
> as you can see
> here:https://git.libre-riscv.org/?p=ieee754fpu.git;a=blobdiff;f=src/add/
> fsqrt.py;h=285492c60f5ef11a5a90c6c11d4a44bdfbc13f89;
> hp=edb7d4ba17ad916b5043cc60a986d6fcc421ec66;
> hb=988c785b20b569cef6f9140401fab2ed413259a4;
> hpb=19fdaa150749a27d4a88d0e9ca3a36ae90c64291
>
> I added two for loops, but when i run it i get the following:
>
> (0, 0)
> (1, 0)
> (1, 0)
> (1, 0)
> (2, 0)
> (2, 0)
> (2, 0)
> (2, 0)
> (2, 0)
> (3, 0)
> .
> .
> .
> .
>
> So it isnt working
you're not looking far enough down the results... also, not having
the original m/e to compare with doesn't help... i added this:
+ ms, es = main(m, e)
+ print("m:%d e:%d sqrt: m:%d e:%d" % (m, e, ms, es))
that gives the original values of the for-loop side-by-side with
the sqrt'ed answer
_now_ it's possible to see that yes, when the exponent is odd,
mantissa is multiplied by 2 before being integer-sqrt'ed.
so....
m:8 e:25 sqrt: m:4 e:12
because e==25, so it gets reduced to 24 and m gets multiplied by 2
which means, now e==24 and m==16
the sqrt of the exponent is 12 (just shift down by one aka "divide by 2")
the sqrt of the mantissa (16) is 4.
m:8 e:24 sqrt: m:2 e:12
because e==24, it does NOT get reduced by 1, so m remains the SAME.
sqrt of exponent e=24 is 12 (div by 2)
sqrt of mantissa (8) is 2 with a LOT of remainder missing.
check that with python floating point..
>>> pow(8.0, 0.5)
2.8284271247461903
wow, so with the integer sqrt we lost a *LOT* of digits in the rounding, there.
but that's ok, we can deal with that later.
--
You are receiving this mail because:
You are on the CC list for the bug.
More information about the libre-riscv-dev
mailing list