[libcxx-commits] [libcxx] [libc++][test][NFC] Use correct number of digits for <numbers> ground-truth values (PR #233664)

Eric Ross via libcxx-commits libcxx-commits at lists.llvm.org
Mon Oct 19 21:01:54 PDT 2026


https://github.com/ZERICO2005 created https://github.com/llvm/llvm-project/pull/233664

Corrects the number of digits used for the `float` hexadecimal literals for the `<numbers>` test. All literals are now exactly representable as `float`. The tested values themselves are unchanged.

Noted here: https://github.com/llvm/llvm-project/pull/222830#discussion_r3985465297


>From 2c41d585070483be1b918af8c9e1919751877322 Mon Sep 17 00:00:00 2001
From: zerico <zerico2005 at gmail.com>
Date: Mon, 19 Oct 2026 21:55:49 -0600
Subject: [PATCH] [libc++][test][NFC] Use correct number of digits for
 <numbers> ground-truth values

---
 libcxx/test/std/numerics/numbers/value.pass.cpp | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/libcxx/test/std/numerics/numbers/value.pass.cpp b/libcxx/test/std/numerics/numbers/value.pass.cpp
index f7205608e476f..fc9aa7ffa2600 100644
--- a/libcxx/test/std/numerics/numbers/value.pass.cpp
+++ b/libcxx/test/std/numerics/numbers/value.pass.cpp
@@ -14,6 +14,9 @@
 #include "test_macros.h"
 
 constexpr bool tests() {
+  // Note: Use arbitrary precision with hundreds of digits when generating these
+  // ground-truth values, and round only once to avoid double-rounding issues.
+
   assert(std::numbers::e == 0x1.5bf0a8b145769p+1);
   assert(std::numbers::e_v<double> == 0x1.5bf0a8b145769p+1);
   assert(std::numbers::e_v<float> == 0x1.5bf0a8p+1f);
@@ -24,11 +27,11 @@ constexpr bool tests() {
 
   assert(std::numbers::log10e == 0x1.bcb7b1526e50ep-2);
   assert(std::numbers::log10e_v<double> == 0x1.bcb7b1526e50ep-2);
-  assert(std::numbers::log10e_v<float> == 0x1.bcb7b15p-2f);
+  assert(std::numbers::log10e_v<float> == 0x1.bcb7b2p-2f);
 
   assert(std::numbers::pi == 0x1.921fb54442d18p+1);
   assert(std::numbers::pi_v<double> == 0x1.921fb54442d18p+1);
-  assert(std::numbers::pi_v<float> == 0x1.921fb54p+1f);
+  assert(std::numbers::pi_v<float> == 0x1.921fb6p+1f);
 
   assert(std::numbers::inv_pi == 0x1.45f306dc9c883p-2);
   assert(std::numbers::inv_pi_v<double> == 0x1.45f306dc9c883p-2);
@@ -40,11 +43,11 @@ constexpr bool tests() {
 
   assert(std::numbers::ln2 == 0x1.62e42fefa39efp-1);
   assert(std::numbers::ln2_v<double> == 0x1.62e42fefa39efp-1);
-  assert(std::numbers::ln2_v<float> == 0x1.62e42fp-1f);
+  assert(std::numbers::ln2_v<float> == 0x1.62e430p-1f);
 
   assert(std::numbers::ln10 == 0x1.26bb1bbb55516p+1);
   assert(std::numbers::ln10_v<double> == 0x1.26bb1bbb55516p+1);
-  assert(std::numbers::ln10_v<float> == 0x1.26bb1bp+1f);
+  assert(std::numbers::ln10_v<float> == 0x1.26bb1cp+1f);
 
   assert(std::numbers::sqrt2 == 0x1.6a09e667f3bcdp+0);
   assert(std::numbers::sqrt2_v<double> == 0x1.6a09e667f3bcdp+0);
@@ -60,11 +63,11 @@ constexpr bool tests() {
 
   assert(std::numbers::egamma == 0x1.2788cfc6fb619p-1);
   assert(std::numbers::egamma_v<double> == 0x1.2788cfc6fb619p-1);
-  assert(std::numbers::egamma_v<float> == 0x1.2788cfp-1f);
+  assert(std::numbers::egamma_v<float> == 0x1.2788d0p-1f);
 
   assert(std::numbers::phi == 0x1.9e3779b97f4a8p+0);
   assert(std::numbers::phi_v<double> == 0x1.9e3779b97f4a8p+0);
-  assert(std::numbers::phi_v<float> == 0x1.9e3779ap+0f);
+  assert(std::numbers::phi_v<float> == 0x1.9e377ap+0f);
 
 #if defined(TEST_LONG_DOUBLE_IS_DOUBLE)
   assert(std::numbers::e_v<long double> == 0x1.5bf0a8b145769p+1L);



More information about the libcxx-commits mailing list