public inbox for newlib@sourceware.org
 help / color / mirror / Atom feed
From: Corinna Vinschen <vinschen@redhat.com>
To: Jesse Huang <jesse.huang@sifive.com>
Cc: newlib@sourceware.org, kito.cheng@gmail.com
Subject: Re: [PATCH] Fix rounding results in lrint() & llrint() when close to 0
Date: Thu, 27 Jul 2023 11:39:04 +0200	[thread overview]
Message-ID: <ZMI7OJlCteDZeNkR@calimero.vinschen.de> (raw)
In-Reply-To: <20230727084940.2138765-1-jesse.huang@sifive.com>

On Jul 27 01:49, Jesse Huang via Newlib wrote:
> soft-fp should round floating pointer numbers according to the current
> rounding mode. However, in the current code of lrint() and llrint(),
> there are if statements before the actual rounding computation
> 
>       if(j0 < -1)
>         return 0;
> 
> Where j0 is the exponent of the floating point number.
> 
> It means any number having a exponent less than -1
> (i.e. interval (-0.5, 0.5)) will be rounded to 0 regardeless of the
> rounding mode.
> 
> The bug already fixed in glibc in 2006 by moving the check afterwards
> the rounding computation, but still persists in newlib.
> 
> This patch fixed it in a similar way to glibc
> Ref Commit in glibc: 6624dbc07b5a9fb316ed188ef01f65b8eea8b47c
> ---
>  newlib/libm/common/s_llrint.c  | 31 +++++++++++--------------------
>  newlib/libm/common/s_lrint.c   | 31 +++++++++++--------------------
>  newlib/libm/common/sf_llrint.c |  6 ++----
>  newlib/libm/common/sf_lrint.c  |  6 ++----
>  4 files changed, 26 insertions(+), 48 deletions(-)

Pushed.


Thanks,
Corinna


      reply	other threads:[~2023-07-27  9:39 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-27  8:49 Jesse Huang
2023-07-27  9:39 ` Corinna Vinschen [this message]

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=ZMI7OJlCteDZeNkR@calimero.vinschen.de \
    --to=vinschen@redhat.com \
    --cc=jesse.huang@sifive.com \
    --cc=kito.cheng@gmail.com \
    --cc=newlib@sourceware.org \
    /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).