logb() vs floor(log2()) (was: Man page issues: logb, significand, cbrt, log2, log10, exp10)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.

Attachment: signature.asc
Description: PGP signature


[Index of Archives]     [Kernel Documentation]     [Netdev]     [Linux Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux