mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-18 17:50:29 +02:00
Include <gmp.h> in numbers.h, not in
numbers.c. (scm_to_mpz, scm_from_mpz): New. Thanks to Andreas Vögele!
This commit is contained in:
parent
9c0485fce2
commit
cd0362604b
2 changed files with 23 additions and 1 deletions
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue