logb() vs floor(log2()) (was: Man page issues: logb, significand, cbrt, log2, log10, exp10)
Alejandro Colomar
alx@kernel.org
Mon Mar 4 17:52:10 GMT 2024
Hi Morten,
On Thu, Feb 29, 2024 at 07:28:10PM -0500, Morten Welinder wrote:
> I came across some minor issues in some math man pages.
>
> M.
>
>
>
> logb:
> The formula "floor(log2(x))" should be "floor(log2(fabs(x)))". (Or
> ...abs(...) if it's meant to be math and not C.)
Confirmed. This is a bug in glibc too, BTW. That text seems to be
copied from their manual.
ISO C says this function is specified in ANSI/IEEE 854, but I don't have
access to that document, so I'm not sure what's the specification of the
function. I'm not sure if it should fail for negative values (like
log2(3)) or not; although the standard mentions the behavior for
negative infinity, so it probably is specified to work for negative
values too.
So, the behavior of the function seems to be correct, and it's just the
manual that needs to be fixed.
I've CCed glibc, in case they want to comment. But yeah, your
suggestion seems correct.
Have a lovely day!
Alex
--
<https://www.alejandro-colomar.es/>
Looking for a remote C programming job at the moment.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/libc-help/attachments/20240304/42c270fb/attachment.sig>
More information about the Libc-help
mailing list