From 59c4186550dcdce8a3764e04e14effc243737706 Mon Sep 17 00:00:00 2001 From: Sergey Fedorov Date: Wed, 29 Jul 2026 07:42:29 +0000 Subject: [PATCH 06/13] folly/ConstexprMath: avoid long-double literals for e_v/ln2_v on ppc32/i386 GCC's constexpr handling of the non-IEEE long double formats on these targets (IBM double-double on Darwin ppc, 80-bit x87 on i386) chokes on the full-precision long-double literals. Use double literals with 36 significant digits there; that still exceeds double-double precision, so no accuracy is lost for the affected targets. Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_013G8CDpEyDCCgV4jaMM9WME --- folly/ConstexprMath.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/folly/ConstexprMath.h b/folly/ConstexprMath.h index 0e14a84a7..603c85263 100644 --- a/folly/ConstexprMath.h +++ b/folly/ConstexprMath.h @@ -62,16 +62,31 @@ using enable_if_floating_t = /// e_v /// /// mimic: std::numbers::e_v, C++20 +/// +/// The shorter literals for ppc32/i386 work around GCC's handling of the +/// non-IEEE long double formats there (IBM double-double on Darwin ppc, +/// 80-bit x87 on i386); 36 significant digits still exceed double-double +/// precision (~32 digits), so no accuracy is lost for those targets. template +#if defined(__ppc__) || defined(__i386__) +inline constexpr T e_v = + detail::enable_if_floating_t(2.71828182845904523536028747135266250); +#else inline constexpr T e_v = detail::enable_if_floating_t( 2.71828182845904523536028747135266249775724709369995L); +#endif /// ln2_v /// /// mimic: std::numbers::ln2_v, C++20 template +#if defined(__ppc__) || defined(__i386__) +inline constexpr T ln2_v = + detail::enable_if_floating_t(0.693147180559945309417232121458176568); +#else inline constexpr T ln2_v = detail::enable_if_floating_t( 0.69314718055994530941723212145817656807550013436025L); +#endif /// e /// -- 2.43.0