[v3,2/4] manual: floor(log2(fabs(x))) has rounding errors

Message ID 20240331203829.23591-3-alx@kernel.org
State Committed
Commit 077613291b271b64fa60b8a22c3b39c9db697b65
Delegated to: DJ Delorie
Series manual: arith.texi and math.texi fixes |


Context Check Description
redhat-pt-bot/TryBot-apply_patch success Patch applied to master at the time it was sent
linaro-tcwg-bot/tcwg_glibc_build--master-aarch64 success Testing passed
linaro-tcwg-bot/tcwg_glibc_check--master-aarch64 success Testing passed
linaro-tcwg-bot/tcwg_glibc_build--master-arm success Testing passed
linaro-tcwg-bot/tcwg_glibc_check--master-arm success Testing passed

Commit Message

Alejandro Colomar March 31, 2024, 8:38 p.m. UTC
  Link: <https://inbox.sourceware.org/libc-alpha/20240305150131.GD3653@qaa.vinc17.org/T/#m3ceecda630012995339bcc5448fee451cf277a8b>
Reported-by: Vincent Lefevre <vincent@vinc17.net>
Suggested-by: Vincent Lefevre <vincent@vinc17.net>
Reviewed-by: DJ Delorie <dj@redhat.com>
Cc: Morten Welinder <mwelinder@gmail.com>
Cc: Adhemerval Zanella Netto <adhemerval.zanella@linaro.org>
Cc: Paul Zimmermann <Paul.Zimmermann@inria.fr>
Cc: Andreas Schwab <schwab@linux-m68k.org>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
 manual/math.texi | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)


diff --git a/manual/math.texi b/manual/math.texi
index c54eaebb65..79bf3a1401 100644
--- a/manual/math.texi
+++ b/manual/math.texi
@@ -560,8 +560,11 @@  These functions return the base-2 logarithm of @var{x}.
 @standardsx{logbfNx, TS 18661-3:2015, math.h}
 These functions extract the exponent of @var{x} and return it as a
-floating-point value.  If @code{FLT_RADIX} is two, @code{logb} is equal
-to @code{floor (log2 (fabs (x)))}, except it's probably faster.
+floating-point value.
+If @code{FLT_RADIX} is two,
+@code{logb (x)} is similar to @code{floor (log2 (fabs (x)))},
+except that the latter may give an incorrect integer
+due to intermediate rounding.
 If @var{x} is de-normalized, @code{logb} returns the exponent @var{x}
 would have if it were normalized.  If @var{x} is infinity (positive or