Skip to content

Commit 0c78485

Browse files
authored
[MathExtras] Favor using the hexadecimal FP constants (#123180)
This just fixes a TODO now that we are using C++17.
1 parent e451429 commit 0c78485

File tree

1 file changed

+30
-31
lines changed

1 file changed

+30
-31
lines changed

llvm/include/llvm/Support/MathExtras.h

Lines changed: 30 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -43,38 +43,37 @@ using common_sint =
4343
/// Mathematical constants.
4444
namespace numbers {
4545
// TODO: Track C++20 std::numbers.
46-
// TODO: Favor using the hexadecimal FP constants (requires C++17).
4746
// clang-format off
48-
constexpr double e = 2.7182818284590452354, // (0x1.5bf0a8b145769P+1) https://oeis.org/A001113
49-
egamma = .57721566490153286061, // (0x1.2788cfc6fb619P-1) https://oeis.org/A001620
50-
ln2 = .69314718055994530942, // (0x1.62e42fefa39efP-1) https://oeis.org/A002162
51-
ln10 = 2.3025850929940456840, // (0x1.26bb1bbb55516P+1) https://oeis.org/A002392
52-
log2e = 1.4426950408889634074, // (0x1.71547652b82feP+0)
53-
log10e = .43429448190325182765, // (0x1.bcb7b1526e50eP-2)
54-
pi = 3.1415926535897932385, // (0x1.921fb54442d18P+1) https://oeis.org/A000796
55-
inv_pi = .31830988618379067154, // (0x1.45f306dc9c883P-2) https://oeis.org/A049541
56-
sqrtpi = 1.7724538509055160273, // (0x1.c5bf891b4ef6bP+0) https://oeis.org/A002161
57-
inv_sqrtpi = .56418958354775628695, // (0x1.20dd750429b6dP-1) https://oeis.org/A087197
58-
sqrt2 = 1.4142135623730950488, // (0x1.6a09e667f3bcdP+0) https://oeis.org/A00219
59-
inv_sqrt2 = .70710678118654752440, // (0x1.6a09e667f3bcdP-1)
60-
sqrt3 = 1.7320508075688772935, // (0x1.bb67ae8584caaP+0) https://oeis.org/A002194
61-
inv_sqrt3 = .57735026918962576451, // (0x1.279a74590331cP-1)
62-
phi = 1.6180339887498948482; // (0x1.9e3779b97f4a8P+0) https://oeis.org/A001622
63-
constexpr float ef = 2.71828183F, // (0x1.5bf0a8P+1) https://oeis.org/A001113
64-
egammaf = .577215665F, // (0x1.2788d0P-1) https://oeis.org/A001620
65-
ln2f = .693147181F, // (0x1.62e430P-1) https://oeis.org/A002162
66-
ln10f = 2.30258509F, // (0x1.26bb1cP+1) https://oeis.org/A002392
67-
log2ef = 1.44269504F, // (0x1.715476P+0)
68-
log10ef = .434294482F, // (0x1.bcb7b2P-2)
69-
pif = 3.14159265F, // (0x1.921fb6P+1) https://oeis.org/A000796
70-
inv_pif = .318309886F, // (0x1.45f306P-2) https://oeis.org/A049541
71-
sqrtpif = 1.77245385F, // (0x1.c5bf8aP+0) https://oeis.org/A002161
72-
inv_sqrtpif = .564189584F, // (0x1.20dd76P-1) https://oeis.org/A087197
73-
sqrt2f = 1.41421356F, // (0x1.6a09e6P+0) https://oeis.org/A002193
74-
inv_sqrt2f = .707106781F, // (0x1.6a09e6P-1)
75-
sqrt3f = 1.73205081F, // (0x1.bb67aeP+0) https://oeis.org/A002194
76-
inv_sqrt3f = .577350269F, // (0x1.279a74P-1)
77-
phif = 1.61803399F; // (0x1.9e377aP+0) https://oeis.org/A001622
47+
constexpr double e = 0x1.5bf0a8b145769P+1, // (2.7182818284590452354) https://oeis.org/A001113
48+
egamma = 0x1.2788cfc6fb619P-1, // (.57721566490153286061) https://oeis.org/A001620
49+
ln2 = 0x1.62e42fefa39efP-1, // (.69314718055994530942) https://oeis.org/A002162
50+
ln10 = 0x1.26bb1bbb55516P+1, // (2.3025850929940456840) https://oeis.org/A002392
51+
log2e = 0x1.71547652b82feP+0, // (1.4426950408889634074)
52+
log10e = 0x1.bcb7b1526e50eP-2, // (.43429448190325182765)
53+
pi = 0x1.921fb54442d18P+1, // (3.1415926535897932385) https://oeis.org/A000796
54+
inv_pi = 0x1.45f306dc9c883P-2, // (.31830988618379067154) https://oeis.org/A049541
55+
sqrtpi = 0x1.c5bf891b4ef6bP+0, // (1.7724538509055160273) https://oeis.org/A002161
56+
inv_sqrtpi = 0x1.20dd750429b6dP-1, // (.56418958354775628695) https://oeis.org/A087197
57+
sqrt2 = 0x1.6a09e667f3bcdP+0, // (1.4142135623730950488) https://oeis.org/A00219
58+
inv_sqrt2 = 0x1.6a09e667f3bcdP-1, // (.70710678118654752440)
59+
sqrt3 = 0x1.bb67ae8584caaP+0, // (1.7320508075688772935) https://oeis.org/A002194
60+
inv_sqrt3 = 0x1.279a74590331cP-1, // (.57735026918962576451)
61+
phi = 0x1.9e3779b97f4a8P+0; // (1.6180339887498948482) https://oeis.org/A001622
62+
constexpr float ef = 0x1.5bf0a8P+1F, // (2.71828183) https://oeis.org/A001113
63+
egammaf = 0x1.2788d0P-1F, // (.577215665) https://oeis.org/A001620
64+
ln2f = 0x1.62e430P-1F, // (.693147181) https://oeis.org/A002162
65+
ln10f = 0x1.26bb1cP+1F, // (2.30258509) https://oeis.org/A002392
66+
log2ef = 0x1.715476P+0F, // (1.44269504)
67+
log10ef = 0x1.bcb7b2P-2F, // (.434294482)
68+
pif = 0x1.921fb6P+1F, // (3.14159265) https://oeis.org/A000796
69+
inv_pif = 0x1.45f306P-2F, // (.318309886) https://oeis.org/A049541
70+
sqrtpif = 0x1.c5bf8aP+0F, // (1.77245385) https://oeis.org/A002161
71+
inv_sqrtpif = 0x1.20dd76P-1F, // (.564189584) https://oeis.org/A087197
72+
sqrt2f = 0x1.6a09e6P+0F, // (1.41421356) https://oeis.org/A002193
73+
inv_sqrt2f = 0x1.6a09e6P-1F, // (.707106781)
74+
sqrt3f = 0x1.bb67aeP+0F, // (1.73205081) https://oeis.org/A002194
75+
inv_sqrt3f = 0x1.279a74P-1F, // (.577350269)
76+
phif = 0x1.9e377aP+0F; // (1.61803399) https://oeis.org/A001622
7877
// clang-format on
7978
} // namespace numbers
8079

0 commit comments

Comments
 (0)