bin/144306: [libm] [patch] Nasty bug in jn(3)
Ulrich Spörlein
uqs at spoerlein.net
Tue Nov 9 20:10:11 UTC 2010
The following reply was made to PR bin/144306; it has been noted by GNATS.
From: Ulrich =?utf-8?B?U3DDtnJsZWlu?= <uqs at spoerlein.net>
To: bug-followup at FreeBSD.org, kargl at troutmask.apl.washington.edu
Cc:
Subject: Re: bin/144306: [libm] [patch] Nasty bug in jn(3)
Date: Tue, 9 Nov 2010 21:02:44 +0100
--IS0zKkzwUGydFO0o
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Hello Steve, I saw your updated patch for jnf(3) on the mailing list and
was wondering what the correct values for your test case would look like?
I'm asking because on Ubuntu I get slightly different values. Especially
disturbing is, that for FreeBSD the jn/jnf values are identical in this
case.
Ubuntu 10.04:
# cc -o testjn -lm testjn.c && ./testjn
2 4.317548e-01
3 1.850071e-01
4 6.121505e-02
5 1.568141e-02
6 3.251921e-03
7 5.737757e-04
8 8.808225e-05
9 1.195869e-05
# cc -o testjnf -lm testjnf.c && ./testjnf
2 4.317548e-01
3 2.126431e-01
4 6.348598e-02
5 1.606404e-02
6 3.341151e-03
7 5.894695e-04
8 9.044447e-05
9 1.228349e-05
FreeBSD -CURRENT:
freebsd64# cc -o testjn -lm testjn.c && ./testjn
2 4.317548e-01
3 1.989999e-01
4 6.474667e-02
5 1.638924e-02
6 3.404818e-03
7 6.006884e-04
8 9.216579e-05
9 1.251727e-05
freebsd64# cc -o testjnf -lm testjnf.c && ./testjnf
2 4.317548e-01
3 1.989999e-01
4 6.474666e-02
5 1.638924e-02
6 3.404818e-03
7 6.006881e-04
8 9.216577e-05
9 1.251727e-05
(both systems are amd64, I tried gcc and clang on FreeBSD, giving the
same results.)
Here's the full patch, for archival purposes:
--IS0zKkzwUGydFO0o
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment; filename="msun.diff"
Content-Transfer-Encoding: 8bit
commit 1db46def1f105e5b8a2d814eeaac46716b1a663c
Author: Ulrich Spörlein <uqs at spoerlein.net>
Date: Tue Nov 9 20:39:57 2010 +0100
Fix bug with jn(3) and jnf(3)
PR: bin/144306
Submitted by: Steven G. Kargl <kargl at troutmask.apl.washington.edu>
diff --git a/lib/msun/src/e_jn.c b/lib/msun/src/e_jn.c
index e277e30..8b0bc62 100644
--- a/lib/msun/src/e_jn.c
+++ b/lib/msun/src/e_jn.c
@@ -200,7 +200,12 @@ __ieee754_jn(int n, double x)
}
}
}
- b = (t*__ieee754_j0(x)/b);
+ z = __ieee754_j0(x);
+ w = __ieee754_j1(x);
+ if (fabs(z) >= fabs(w))
+ b = (t*z/b);
+ else
+ b = (t*w/a);
}
}
if(sgn==1) return -b; else return b;
diff --git a/lib/msun/src/e_jnf.c b/lib/msun/src/e_jnf.c
index 3bbf7b7..d045bb05 100644
--- a/lib/msun/src/e_jnf.c
+++ b/lib/msun/src/e_jnf.c
@@ -152,7 +152,12 @@ __ieee754_jnf(int n, float x)
}
}
}
- b = (t*__ieee754_j0f(x)/b);
+ z = __ieee754_j0f(x);
+ w = __ieee754_j1f(x);
+ if (fabs(z) >= fabs(w))
+ b = (t*z/b);
+ else
+ b = (t*w/a);
}
}
if(sgn==1) return -b; else return b;
--IS0zKkzwUGydFO0o--
More information about the freebsd-bugs
mailing list