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: 9 Nov 2007 22:30:09 -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-09 22:30 -------
The following asm stub passes all my tests cases for llround.
lis 9,.LC0@ha
lfd 9,.LC0@l(9) /* Load 2^52 into fpr9. */
lfs 10,.LC0@l+8(9) /* Load 0.5 into fpr10 using r9 as the base
register. */
fabs 2, 1 /* Get the absolute value of x. */
fsub 12,10,10 /* Compute 0.0 and put it in fpr12. */
fcmpu 6, 2, 10 /* if |x| < 0.5 */
fcmpu 4, 2, 9 /* if |x| >= 2^52 */
fcmpu 3, 1, 12 /* x is negative? x < 0.0 */
blt- 6,.Lretzero /* 0.5 > x < -0.5 so just return 0. */
bge- 4,.Lnobias /* 2^52 > x < -2^52 just convert with no bias. */
fadd 3,2,10 /* |x|+=0.5 bias to prepare to round. */
bge 3,.Lconvert /* x is positive so don't negate x. */
fnabs 3,3 /* -(|x|+=0.5) */
.Lconvert:
fctidz 4,3 /* Convert to Integer double word round toward
0. */
stfd 4,8(1)
nop
nop
nop
lwz 4,12(1) /* Load return as integer. */
lwz 3,8(1)
lwz 3,8(1)
.Lout:
addi 1,1,16
blr
.Lretzero: /* 0.5 > x > -0.5 */
li 3,0 /* return 0. */
li 4,0
b .Lout
.Lnobias:
fmr 3,2
b .Lconvert
--
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.