From: Alejandro Colomar Date: Sun, 31 Mar 2024 20:38:44 +0000 (+0200) Subject: manual: floor(log2(fabs(x))) has rounding errors X-Git-Tag: glibc-2.40~305 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=077613291b271b64fa60b8a22c3b39c9db697b65;p=thirdparty%2Fglibc.git manual: floor(log2(fabs(x))) has rounding errors Link: Reported-by: Vincent Lefevre Suggested-by: Vincent Lefevre Reviewed-by: DJ Delorie Cc: Morten Welinder Cc: Adhemerval Zanella Netto Cc: Paul Zimmermann Cc: Andreas Schwab Signed-off-by: Alejandro Colomar --- 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} @safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}} 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