From: Bruno Haible Date: Mon, 7 Jul 2025 15:02:45 +0000 (+0200) Subject: float-h: Enforce the ISO C 23 compliant value for LDBL_EPSILON. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ce8e9de0bf34bc63dffc67ab384334c509175f64;p=thirdparty%2Fgnulib.git float-h: Enforce the ISO C 23 compliant value for LDBL_EPSILON. Reported by Cosima Neidahl in . * lib/float.in.h (LDBL_EPSILON): Override on all PowerPC platforms. --- diff --git a/ChangeLog b/ChangeLog index 9d62b1615e..d09840c10d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2025-07-07 Bruno Haible + + float-h: Enforce the ISO C 23 compliant value for LDBL_EPSILON. + Reported by Cosima Neidahl in + . + * lib/float.in.h (LDBL_EPSILON): Override on all PowerPC platforms. + 2025-07-07 Bruno Haible vasnprintf: Fix -Wswitch-unreachable warning. diff --git a/lib/float.in.h b/lib/float.in.h index 86af55ad1b..4759e83478 100644 --- a/lib/float.in.h +++ b/lib/float.in.h @@ -181,6 +181,21 @@ extern const union gl_long_double_union gl_LDBL_MAX; # endif #endif +/* On PowerPC platforms, 'long double' has a double-double representation. + Up to ISO C 17, this was outside the scope of ISO C because it can represent + numbers with mantissas of the form 1.<52 bits><52 bits>, such as + 1.0L + 4.94065645841246544176568792868221e-324L = 1 + 2^-1074; see + ISO C 17 § 5.2.4.2.2.(3). + In ISO C 23, wording has been included that makes this 'long double' + representation compliant; see ISO C 23 § 5.2.5.3.3.(8)-(9). In this setting, + numbers with mantissas of the form 1.<52 bits><52 bits> are + called "unnormalized". And since LDBL_EPSILON must be normalized (per + ISO C 23 § 5.2.5.3.3.(33)), it must be 2^-105. */ +#if defined __powerpc__ && LDBL_MANT_DIG == 106 +# undef LDBL_EPSILON +# define LDBL_EPSILON 2.46519032881566189191165176650870696773e-32L /* 2^-105 */ +#endif + /* ============================ ISO C11 support ============================ */ /* 'float' properties */