TheThirdOne / rars

RARS -- RISC-V Assembler and Runtime Simulator
Other
1.14k stars 217 forks source link

Error in Floating Point Representation tool about subnormal numbers? #201

Open pacalet opened 8 months ago

pacalet commented 8 months ago

According IEEE 754-2019:

As a consequence for 32 bits precision the value of subnormal numbers shall be $v = (-1)^S \times 2^{-126} \times (0 + 2^{-23} \times T)$. The Floating Point Representation tool apparently has a different interpretation and displays equation $v = (-1)^S \times 2^{-127} \times 2^{-23} \times T$. The first screenshot below shows the tool for $S = 0, E = 0, T = 1$. Still, it displays the correct scientific notation: 1.4E-45 instead of the wrong $v = 2^{-127} \times 2^{-23} = 2^{-150} \approx 7e^{-46}$.

I suggest to replace $0 - 127$ with $-126$, $2^{-127}$ with $2^{-126}$ and, while we are at it, denormalized with the new standard subnormal term. Pull request submitted, new screenshot added with the correct display.

rars-fp

rars-fp-fixed