summaryrefslogtreecommitdiff
path: root/mpfr-impl.h
diff options
context:
space:
mode:
authorzimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4>1999-07-05 10:51:37 +0000
committerzimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4>1999-07-05 10:51:37 +0000
commitabcdd22477130958346fa1e4c332a4b68075d78c (patch)
tree0961a93b685f26f24a37faadecdf57ac1e7a542f /mpfr-impl.h
parenta229e6f2976a56af9dc3c17d6ccddf416d5aaa92 (diff)
downloadmpfr-abcdd22477130958346fa1e4c332a4b68075d78c.tar.gz
include file for mpfr developers only
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@281 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'mpfr-impl.h')
-rw-r--r--mpfr-impl.h23
1 files changed, 23 insertions, 0 deletions
diff --git a/mpfr-impl.h b/mpfr-impl.h
new file mode 100644
index 000000000..5606ff70b
--- /dev/null
+++ b/mpfr-impl.h
@@ -0,0 +1,23 @@
+/* generate a random double using the whole range of possible values,
+ including denormalized numbers, NaN, infinities, ... */
+double drand()
+{
+ double d; int *i;
+
+ i = (int*) &d;
+ i[0] = lrand48();
+ i[1] = lrand48();
+ if (lrand48()%2) d=-d; /* generates negative numbers */
+ return d;
+}
+
+/* returns the number of ulp's between a and b */
+int ulp(a,b) double a,b;
+{
+ double eps=1.1102230246251565404e-16; /* 2^(-53) */
+ b = (a-b)/a;
+ if (b>0)
+ return (int) floor(b/eps);
+ else
+ return (int) ceil(b/eps);
+}