This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: Fix powerpc32 lround, lroundf spurious exceptions (bug 19134) [committed]
- From: Joseph Myers <joseph at codesourcery dot com>
- To: Matt Turner <mattst88 at gmail dot com>
- Cc: GNU C Library <libc-alpha at sourceware dot org>
- Date: Wed, 14 Oct 2015 22:39:19 +0000
- Subject: Re: Fix powerpc32 lround, lroundf spurious exceptions (bug 19134) [committed]
- Authentication-results: sourceware.org; auth=none
- References: <alpine dot DEB dot 2 dot 10 dot 1510142114370 dot 2045 at digraph dot polyomino dot org dot uk> <CAEdQ38E4LaYY9DO=X3iAJcwvxwgMkwhFqg05XCDs+TRzY_jNpw at mail dot gmail dot com>
On Wed, 14 Oct 2015, Matt Turner wrote:
> On Wed, Oct 14, 2015 at 2:15 PM, Joseph Myers <joseph@codesourcery.com> wrote:
> > Committed. Any optimizations of this code anyone may wish to make are of
> > course welcome.
>
> The code seems to do the (|x| + 0.5) and round towards zero trick,
> which it notes does not work for an input of nextafter(0.5, 0.0)
> (i.e., 0x1.fffffffffffffp-2):
>
> > It is necessary to detect when x is (+-)0x1.fffffffffffffp-2 because adding +-0.5 in this case will cause an erroneous shift, carry and round. We simply return 0 if 0.5 > x > -0.5.
>
> and so it handles 0.5 > x > -0.5 specially. Can it not simply add
> 0x1.fffffffffffffp-2 instead of 0.5 and remove the special case?
No, that wouldn't work for any argument of the form x.5 in
round-toward-zero mode.
--
Joseph S. Myers
joseph@codesourcery.com