Fix powerpc32 lround, lroundf spurious exceptions (bug 19134) [committed]
Joseph Myers
joseph@codesourcery.com
Wed Oct 14 22:39:00 GMT 2015
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
More information about the Libc-alpha
mailing list