This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: Clean up dbl-64 rint, nearbyint
On Tuesday, March 13, 2012 01:45:11 Joseph S. Myers wrote:
> Thomas's comments about applying fixes globally to all instances
> reminded me of an item on my glibc todo list to apply my
> rintf/nearbyintf fixes to other instances of those functions. This
> patch does so for the dbl-64 versions (ldbl-128 appears to have been
> the only other affected version, and was fixed by David Miller because
> there turned out to be an actual bug in the unnecessary code).
> <http://sourceware.org/ml/libc-alpha/2012-02/msg00397.html> explains
> the general issue here; I don't know any actual bug fixed by this
> cleanup, but it still seems desirable.
>
> Tested x86_64 --disable-multi-arch (directly for the wordsize-64
> versions; the non-wordsize-64 versions were tested on x86_64 by
> copying them to the wordsize-64 directory so they got used).
>
> Richard, looking at other versions of these functions I'm suspicious
> of the alpha versions of nearbyint and nearbyintf (which just add and
> subtract 0x1p23 or 0x1p52 without checking the size of the argument).
> At least for normal IEEE arithmetic, that's not correct (for double,
> consider an argument of 0x1p52 + 1, for example, which is an integer
> but whose value will be changed when 0x1p52 is added and subtracted).
> If the alpha versions do indeed get such cases wrong I guess it's
> evidence we need more testcases for rint and nearbyint to cover these
> cases of large integer arguments.
>
> 2012-03-12 Joseph Myers <joseph@codesourcery.com>
>
> * sysdeps/ieee754/dbl-64/s_nearbyint.c (__nearbyint): Do not
> manipulate bits before adding and subtracting TWO52[sx].
> * sysdeps/ieee754/dbl-64/s_rint.c (__rint): Likewise.
> * sysdeps/ieee754/dbl-64/wordsize-64/s_nearbyint.c (__nearbyint):
> Likewise.
> * sysdeps/ieee754/dbl-64/wordsize-64/s_rint.c (__rint): Likewise.
Thanks, those are fine,
Andreas
--
Andreas Jaeger aj@{suse.com,opensuse.org} Twitter/Identica: jaegerandi
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn,Jennifer Guild,Felix Imendörffer,HRB16746 (AG Nürnberg)
GPG fingerprint = 93A3 365E CE47 B889 DF7F FED1 389A 563C C272 A126