From: Alejandro Colomar <alx@kernel.org>
To: Vincent Lefevre <vincent@vinc17.net>,
libc-alpha@sourceware.org, Morten Welinder <mwelinder@gmail.com>,
Adhemerval Zanella Netto <adhemerval.zanella@linaro.org>
Subject: Re: [PATCH] manual: logb(x) is floor(log2(fabs(x)))
Date: Tue, 5 Mar 2024 12:10:23 +0100 [thread overview]
Message-ID: <Zeb9n9SEY6ZqW6eX@debian> (raw)
In-Reply-To: <20240305100251.GB3653@qaa.vinc17.org>
[-- Attachment #1: Type: text/plain, Size: 1709 bytes --]
Hi Vincent!
On Tue, Mar 05, 2024 at 11:02:51AM +0100, Vincent Lefevre wrote:
> On 2024-03-04 23:40:59 +0100, Alejandro Colomar wrote:
> > log2(3) doesn't accept negative input, but it seems logb(3) does
> > accept it.
>
> Yes, but unrelated to that, there was an issue with the text before.
>
> > 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>
> > Signed-off-by: Alejandro Colomar <alx@kernel.org>
> > ---
> > manual/math.texi | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/manual/math.texi b/manual/math.texi
> > index 2f6ee253b9..bf4027c4ee 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.
>
> No, it isn't necessarily equal. The code floor (log2 (fabs ((x)))
> can give an incorrect result due to rounding if x is just before
> a power of 2, in particular if x is large.
Hmmm, the bug is different, so how about a second patch for fixing that?
For that, I'd do s/equal/similar/ and s/faster/more accurate/. Does it
sound good to you?
Have a lovely day!
Alex
--
<https://www.alejandro-colomar.es/>
Looking for a remote C programming job at the moment.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2024-03-05 11:10 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <ZeZIVzJ_Wl42SnF2@debian>
2024-03-04 22:40 ` Alejandro Colomar
2024-03-05 10:02 ` Vincent Lefevre
2024-03-05 11:10 ` Alejandro Colomar [this message]
2024-03-05 11:37 ` Vincent Lefevre
2024-03-05 12:30 ` Alejandro Colomar
2024-03-05 13:16 ` Morten Welinder
2024-03-05 15:01 ` Vincent Lefevre
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Zeb9n9SEY6ZqW6eX@debian \
--to=alx@kernel.org \
--cc=adhemerval.zanella@linaro.org \
--cc=libc-alpha@sourceware.org \
--cc=mwelinder@gmail.com \
--cc=vincent@vinc17.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).