[libc][math] Update error bound for log1p to compensate for directional rounding. (#87893)

This commit is contained in:
lntue 2024-04-06 17:38:20 -04:00 committed by GitHub
parent bd9486b4ec
commit 5f7b133e32
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 3 deletions

View File

@ -28,8 +28,9 @@ using LIBC_NAMESPACE::operator""_u128;
namespace {
// Extra errors from P is from using x^2 to reduce evaluation latency.
constexpr double P_ERR = 0x1.0p-50;
// Extra errors from P is from using x^2 to reduce evaluation latency and
// directional rounding.
constexpr double P_ERR = 0x1.0p-49;
// log(2) with 128-bit precision generated by SageMath with:
// def format_hex(value):

View File

@ -34,7 +34,7 @@ TEST_F(LlvmLibcLog1pTest, SpecialNumbers) {
}
TEST_F(LlvmLibcLog1pTest, TrickyInputs) {
constexpr int N = 41;
constexpr int N = 42;
constexpr uint64_t INPUTS[N] = {
0x3ff0000000000000, // x = 1.0
0x4024000000000000, // x = 10.0
@ -65,6 +65,7 @@ TEST_F(LlvmLibcLog1pTest, TrickyInputs) {
0x3c90c40cef04efb5, 0x449d2ccad399848e, 0x4aa12ccdffd9d2ec,
0x5656f070b92d36ce, 0x6db06dcb74f76bcc, 0x7f1954e72ffd4596,
0x5671e2f1628093e4, 0x73dac56e2bf1a951, 0x8001bc6879ea14c5,
0x45ca5f497ec291df, // x = 0x1.a5f497ec291dfp+93
};
for (int i = 0; i < N; ++i) {
double x = FPBits(INPUTS[i]).get_val();