git: 2b2cd97844b8 - main - msun: Fix math error in comment explaining y reduction
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 12 Apr 2024 22:17:26 UTC
The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=2b2cd97844b81e4a45504c90a791c3c3509898ad commit 2b2cd97844b81e4a45504c90a791c3c3509898ad Author: Henri Chataing <henrichataing@google.com> AuthorDate: 2024-04-12 22:08:01 +0000 Commit: Warner Losh <imp@FreeBSD.org> CommitDate: 2024-04-12 22:15:04 +0000 msun: Fix math error in comment explaining y reduction x = k + y for some integer k and |y| < 1/2 exp2(x) = exp2(k + y) = exp2(k) * exp2(y) which can be written as 2**k * exp2(y) The original had x = 2**k + y, which is has an extra 2** in it which isn't correct. Confirmed by forumula 2 in Gal and Bachelis referenced in the comments for the source of this method https://dl.acm.org/doi/pdf/10.1145/103147.103151 The actual code is correct. Reviewed by: imp (who added s_exp2.c and wrote the commit message) Pull Request: https://github.com/freebsd/freebsd-src/pull/1127 --- lib/msun/src/s_exp2.c | 2 +- lib/msun/src/s_exp2f.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/msun/src/s_exp2.c b/lib/msun/src/s_exp2.c index 338312f0de97..2064d22f44f3 100644 --- a/lib/msun/src/s_exp2.c +++ b/lib/msun/src/s_exp2.c @@ -314,7 +314,7 @@ static const double tbl[TBLSIZE * 2] = { * Method: (accurate tables) * * Reduce x: - * x = 2**k + y, for integer k and |y| <= 1/2. + * x = k + y, for integer k and |y| <= 1/2. * Thus we have exp2(x) = 2**k * exp2(y). * * Reduce y: diff --git a/lib/msun/src/s_exp2f.c b/lib/msun/src/s_exp2f.c index 85edd611944e..c863b7512194 100644 --- a/lib/msun/src/s_exp2f.c +++ b/lib/msun/src/s_exp2f.c @@ -72,7 +72,7 @@ static const double exp2ft[TBLSIZE] = { * Method: (equally-spaced tables) * * Reduce x: - * x = 2**k + y, for integer k and |y| <= 1/2. + * x = k + y, for integer k and |y| <= 1/2. * Thus we have exp2f(x) = 2**k * exp2(y). * * Reduce y: