https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120993

Bruno Haible <bruno at clisp dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bruno at clisp dot org

--- Comment #4 from Bruno Haible <bruno at clisp dot org> ---
> One simple fix would be to change LDBL_MANT_DIG, LDBL_MAX_EXP,
> and LDBL_NORM_MAX to equal DBL_MANT_DIG, DBL_MAX_EXP and DBL_NORM_MAX
> respectively.

I don't think changing LDBL_MANT_DIG is adequate, because
  - There's a lot of code that assumes that when
    LDBL_MANT_DIG == DBL_MANT_DIG, 'long double' and 'double' are
    in fact the same.
  - There's also a lot of code that assumes that LDBL_MANT_DIG == 106
    indicates the 'double-double' representation.

I also don't think ISO C 23 requires it:

ISO C 23 ยง 5.2.5.3.3.(2)-(9) defines the characteristics of the floating-point
data type.

It is always possible to reduce p to any value > 1.  For example one could
define
the floating-point model of IEEE 'double' as having p = 5 instead of p = 53.
This would only mean that many more floating-point values would be outside the
model.

Therefore, in order to get a practically useful model, one should choose the
maximum
possible value of p.

In the case of the 'double-double' representation, this value is p = 106.

Namely, every
   x = s * b^e * (f_1 * b^-1 + ... + f_106 * b^-106)
can be represented as a 'double-double' as follows:
If f_54 ... f_106 are all zero, set x_low = 0.
Otherwise let i be the minimum i >= 54 with f_i != 0
and define
   x_low = s * b^(e-i+1) * (f_i * b^-1 + ... + f_106 * b^(i-107))
(which has 107-i <= 53 bits in its significand).
Then
   x = s * b^e * (f_1 * b^-1 + ... + f_53 * b^-53) + x_low.

So, just as pointless as it would be to define DBL_MANT_DIG to any value < 53,
it is pointless to define LDBL_MANT_DIG to any value < 106.

Reply via email to