Re: [PATCH] Fix rounding results in lrint() & llrint() when close to 0

Corinna Vinschen <[email protected]>
Newsgroups gmane.comp.lib.newlib
Message-ID <[email protected]>
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.