summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarius Vollmer <mvo@zagadka.de>2004-09-21 00:42:30 +0000
committerMarius Vollmer <mvo@zagadka.de>2004-09-21 00:42:30 +0000
commitcd0362604b117133b49bb18596c59143dbf7d14f (patch)
tree76d5bf26f134ea8f7d4425944fe1594e9804b381
parent9c0485fce24cb96796265f0602cb092fa8410de1 (diff)
downloadguile-cd0362604b117133b49bb18596c59143dbf7d14f.tar.gz
Include <gmp.h> in numbers.h, not in
numbers.c. (scm_to_mpz, scm_from_mpz): New. Thanks to Andreas Vögele!
-rw-r--r--libguile/numbers.c18
-rw-r--r--libguile/numbers.h6
2 files changed, 23 insertions, 1 deletions
diff --git a/libguile/numbers.c b/libguile/numbers.c
index e14a93ebe..2c9a7ea6f 100644
--- a/libguile/numbers.c
+++ b/libguile/numbers.c
@@ -50,7 +50,6 @@
#include <math.h>
#include <ctype.h>
#include <string.h>
-#include <gmp.h>
#include "libguile/_scm.h"
#include "libguile/feature.h"
@@ -5680,6 +5679,23 @@ scm_is_unsigned_integer (SCM val, scm_t_uintmax min, scm_t_uintmax max)
#endif
+void
+scm_to_mpz (SCM val, mpz_t rop)
+{
+ if (SCM_I_INUMP (val))
+ mpz_set_si (rop, SCM_I_INUM (val));
+ else if (SCM_BIGP (val))
+ mpz_set (rop, SCM_I_BIG_MPZ (val));
+ else
+ scm_wrong_type_arg_msg (NULL, 0, val, "exact integer");
+}
+
+SCM
+scm_from_mpz (mpz_t val)
+{
+ return scm_i_mpz2num (val);
+}
+
int
scm_is_real (SCM val)
{
diff --git a/libguile/numbers.h b/libguile/numbers.h
index 4e39a2cc1..f663e9e85 100644
--- a/libguile/numbers.h
+++ b/libguile/numbers.h
@@ -22,6 +22,8 @@
+#include <gmp.h>
+
#include "libguile/__scm.h"
#include "libguile/print.h"
@@ -323,6 +325,10 @@ SCM_API SCM scm_from_uint64 (scm_t_uint64 x);
#endif
+SCM_API void scm_to_mpz (SCM x, mpz_t rop);
+SCM_API SCM scm_from_mpz (mpz_t rop);
+
+
/* The conversion functions for other types are aliased to the
appropriate ones from above. We pick the right one based on the
size of the type.