This is the mail archive of the
glibc-bugs@sourceware.org
mailing list for the glibc project.
[Bug math/4997] lround(nexafter(0.5,-1)) has incorrect value
- From: "rsa at us dot ibm dot com" <sourceware-bugzilla at sourceware dot org>
- To: glibc-bugs at sources dot redhat dot com
- Date: 8 Nov 2007 18:53:35 -0000
- Subject: [Bug math/4997] lround(nexafter(0.5,-1)) has incorrect value
- References: <20070906173748.4997.fxcoudert@gcc.gnu.org>
- Reply-to: sourceware-bugzilla at sourceware dot org
------- Additional Comments From rsa at us dot ibm dot com 2007-11-08 18:53 -------
The following asm stub resolves the issue by returning 'zero' if 0.5 > x > -0.5.
fsub fp10,fp0,fp0 /* Compute 0.0. */
fabs fp2, fp1 /* Get the absolute value of x. */
fcmpu cr3, fp1, fp10 /* orig x is negative? x < 0.0 */
fcmpu cr6, fp2, fp0 /* if |x| < 0.5 */
ble- cr6,.Lretzero
fadd fp3,fp2,fp0 /* |x|+=0.5 bias to prepare to round. */
bge cr3,.Lconvert /* orig x was positive so don't negate ans. */
fnabs fp2,fp3 /* -(|x|+=0.5) */
.Lconvert:
fctiwz fp4,fp2 /* Convert to Integer DW lround toward 0. */
stfd fp4,8(r1)
nop
nop
nop
lwz r3,12(r1) /* Load return as integer. */
.Lout:
addi r1,r1,16
blr
.Lretzero: /* 0.5 > x > -0.5 */
li r3,0 /* return 0. */
b .Lout
I need to identify all the places where the erroneous rounding is happening,
apply this fix and also apply a check where x > 2^52 for llround. This may also
be an issue for round(). Patch forthcoming.
--
http://sourceware.org/bugzilla/show_bug.cgi?id=4997
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.