[v2,1/3] manual: logb(x) is floor(log2(fabs(x)))

Message ID 20240305161213.14364-2-alx@kernel.org
State Committed
Commit b7d15bd1f00ae3f941150c9e49e65fbc6595adda
Delegated to: DJ Delorie
Headers
Series manual/math.texi: logb(3) and cbrt(3) fixes |

Checks

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 5, 2024, 4:12 p.m. UTC
  log2(3) doesn't accept negative input, but it seems logb(3) does accept
it.

Link: <https://lore.kernel.org/linux-man/ZeYKUOKYS7G90SaV@debian/T/#u>
Reported-by: Morten Welinder <mwelinder@gmail.com>
Cc: Adhemerval Zanella Netto <adhemerval.zanella@linaro.org>
Cc: Vincent Lefevre <vincent@vinc17.net>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
---
 manual/math.texi | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

DJ Delorie March 29, 2024, 10:08 p.m. UTC | #1
Alejandro Colomar <alx@kernel.org> writes:
> -to @code{floor (log2 (      x ))}, except it's probably faster.
> +to @code{floor (log2 (fabs (x)))}, except it's probably faster.

Confirmed that the only change here is the addition of fabs()

Confirmed that logb() accepts negative numbers

LGTM
Reviewed-by: DJ Delorie <dj@redhat.com>
  
Alejandro Colomar March 29, 2024, 11 p.m. UTC | #2
Hi DJ,

On Fri, Mar 29, 2024 at 06:08:19PM -0400, DJ Delorie wrote:
> Alejandro Colomar <alx@kernel.org> writes:
> > -to @code{floor (log2 (      x ))}, except it's probably faster.
> > +to @code{floor (log2 (fabs (x)))}, except it's probably faster.
> 
> Confirmed that the only change here is the addition of fabs()
> 
> Confirmed that logb() accepts negative numbers
> 
> LGTM
> Reviewed-by: DJ Delorie <dj@redhat.com>

Thanks!

Have a lovely night!
Alex
  

Patch

diff --git a/manual/math.texi b/manual/math.texi
index 2f6ee253b9..c54eaebb65 100644
--- a/manual/math.texi
+++ b/manual/math.texi
@@ -561,7 +561,7 @@  These functions return the base-2 logarithm of @var{x}.
 @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 (x))}, except it's probably faster.
+to @code{floor (log2 (fabs (x)))}, except it's probably faster.
 
 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