summaryrefslogtreecommitdiff
path: root/mpz/cmp_d.c
diff options
context:
space:
mode:
authorKevin Ryde <user42@zip.com.au>2001-04-21 23:58:06 +0200
committerKevin Ryde <user42@zip.com.au>2001-04-21 23:58:06 +0200
commitaa8fb3b64e6ef4849abbe830fa60b1dffd1ffc9a (patch)
treedaece21ad80c8140c11d27fef3ed2b4a8c5d2c7c /mpz/cmp_d.c
parentc4cf86f438e2ff30726b682fa754b112050ba98f (diff)
downloadgmp-aa8fb3b64e6ef4849abbe830fa60b1dffd1ffc9a.tar.gz
* mpz/cmp_d.c, mpz/cmpabs_d.c: New files.
Diffstat (limited to 'mpz/cmp_d.c')
-rw-r--r--mpz/cmp_d.c46
1 files changed, 46 insertions, 0 deletions
diff --git a/mpz/cmp_d.c b/mpz/cmp_d.c
new file mode 100644
index 000000000..2f8e70308
--- /dev/null
+++ b/mpz/cmp_d.c
@@ -0,0 +1,46 @@
+/* mpz_cmp_d -- compare mpz and double.
+
+Copyright 2001 Free Software Foundation, Inc.
+
+This file is part of the GNU MP Library.
+
+The GNU MP Library is free software; you can redistribute it and/or modify
+it under the terms of the GNU Lesser General Public License as published by
+the Free Software Foundation; either version 2.1 of the License, or (at your
+option) any later version.
+
+The GNU MP Library is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+License for more details.
+
+You should have received a copy of the GNU Lesser General Public License
+along with the GNU MP Library; see the file COPYING.LIB. If not, write to
+the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+MA 02111-1307, USA.
+*/
+
+#include "gmp.h"
+#include "gmp-impl.h"
+
+int
+mpz_cmp_d (mpz_srcptr z, double d)
+{
+ mp_limb_t darray[LIMBS_PER_DOUBLE];
+ mpf_t u, v;
+ int zsize;
+
+ zsize = SIZ(z);
+ if (d == 0.0)
+ return zsize;
+
+ SIZ(u) = zsize;
+ EXP(u) = ABS(zsize);
+ PTR(u) = PTR(z);
+
+ PTR(v) = darray;
+ SIZ(v) = (d >= 0.0 ? LIMBS_PER_DOUBLE : -LIMBS_PER_DOUBLE);
+ EXP(v) = __gmp_extract_double (darray, ABS(d));
+
+ return mpf_cmp (u, v);
+}