Skip to content

Commit 5f7b133

Browse files
authored
[libc][math] Update error bound for log1p to compensate for directional rounding. (#87893)
1 parent bd9486b commit 5f7b133

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

libc/src/math/generic/log1p.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,9 @@ using LIBC_NAMESPACE::operator""_u128;
2828

2929
namespace {
3030

31-
// Extra errors from P is from using x^2 to reduce evaluation latency.
32-
constexpr double P_ERR = 0x1.0p-50;
31+
// Extra errors from P is from using x^2 to reduce evaluation latency and
32+
// directional rounding.
33+
constexpr double P_ERR = 0x1.0p-49;
3334

3435
// log(2) with 128-bit precision generated by SageMath with:
3536
// def format_hex(value):

libc/test/src/math/log1p_test.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ TEST_F(LlvmLibcLog1pTest, SpecialNumbers) {
3434
}
3535

3636
TEST_F(LlvmLibcLog1pTest, TrickyInputs) {
37-
constexpr int N = 41;
37+
constexpr int N = 42;
3838
constexpr uint64_t INPUTS[N] = {
3939
0x3ff0000000000000, // x = 1.0
4040
0x4024000000000000, // x = 10.0
@@ -65,6 +65,7 @@ TEST_F(LlvmLibcLog1pTest, TrickyInputs) {
6565
0x3c90c40cef04efb5, 0x449d2ccad399848e, 0x4aa12ccdffd9d2ec,
6666
0x5656f070b92d36ce, 0x6db06dcb74f76bcc, 0x7f1954e72ffd4596,
6767
0x5671e2f1628093e4, 0x73dac56e2bf1a951, 0x8001bc6879ea14c5,
68+
0x45ca5f497ec291df, // x = 0x1.a5f497ec291dfp+93
6869
};
6970
for (int i = 0; i < N; ++i) {
7071
double x = FPBits(INPUTS[i]).get_val();

0 commit comments

Comments
 (0)