On Mai 07 2025, Richard Henderson wrote:

> +    /* Convert the 3 digit decimal exponent to binary. */
> +    exp = ((hi >> 24) & 0xf)
> +        + ((hi >> 20) & 0xf) * 10
> +        + ((hi >> 16) & 0xf) * 100;

This is backwards.  An exponent of 123 is stored as 0x01230000, not
0x03210000.

> +    for (int i = 24; exp10; i -= 4, exp10 /= 10) {
> +        res_hi |= (exp10 % 10) << i;

Again, this is backwards.  Also, the decimal exponent of an extended
precision number can be as big as 4951.  From the fpsp040:

| A15. Convert the exponent to bcd.
|      As in A14 above, the exp is converted to bcd and the
|      digits are stored in the final string.
|
|      Digits are stored in L_SCR1(a6) on return from BINDEC as:
|
|        32               16 15                0
|       -----------------------------------------
|       |  0 | e3 | e2 | e1 | e4 |  X |  X |  X |
|       -----------------------------------------

That is, the fourth digit of the exponent is stored in the upper 4 bits
of the padding (OPERR is set if e4 is non-zero).

-- 
Andreas Schwab, sch...@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."

Reply via email to