1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-17 01:00:20 +02:00

Implement 'exact-integer?' and 'scm_is_exact_integer'.

* libguile/numbers.c (scm_exact_integer_p, scm_is_exact_integer):
  New procedures.
  (scm_integer_p): Improve docstring.

* libguile/numbers.h (scm_exact_integer_p, scm_is_exact_integer):
  New prototypes.

* doc/ref/api-data.texi (Integers): Add docs.

* test-suite/tests/numbers.test ("exact-integer?"): Add tests.
This commit is contained in:
Mark H Weaver 2013-12-20 18:12:37 -05:00
parent f659df4495
commit 900a897cd3
4 changed files with 72 additions and 4 deletions

View file

@ -6515,8 +6515,8 @@ SCM_DEFINE (scm_rational_p, "rational?", 1, 0, 0,
SCM_DEFINE (scm_integer_p, "integer?", 1, 0, 0,
(SCM x),
"Return @code{#t} if @var{x} is an integer number, @code{#f}\n"
"else.")
"Return @code{#t} if @var{x} is an integer number,\n"
"else return @code{#f}.")
#define FUNC_NAME s_scm_integer_p
{
if (SCM_I_INUMP (x) || SCM_BIGP (x))
@ -6531,6 +6531,19 @@ SCM_DEFINE (scm_integer_p, "integer?", 1, 0, 0,
}
#undef FUNC_NAME
SCM_DEFINE (scm_exact_integer_p, "exact-integer?", 1, 0, 0,
(SCM x),
"Return @code{#t} if @var{x} is an exact integer number,\n"
"else return @code{#f}.")
#define FUNC_NAME s_scm_exact_integer_p
{
if (SCM_I_INUMP (x) || SCM_BIGP (x))
return SCM_BOOL_T;
else
return SCM_BOOL_F;
}
#undef FUNC_NAME
SCM scm_i_num_eq_p (SCM, SCM, SCM);
SCM_PRIMITIVE_GENERIC (scm_i_num_eq_p, "=", 0, 2, 1,
@ -9603,6 +9616,12 @@ scm_is_integer (SCM val)
return scm_is_true (scm_integer_p (val));
}
int
scm_is_exact_integer (SCM val)
{
return scm_is_true (scm_exact_integer_p (val));
}
int
scm_is_signed_integer (SCM val, scm_t_intmax min, scm_t_intmax max)
{

View file

@ -243,6 +243,7 @@ SCM_API SCM scm_complex_p (SCM x);
SCM_API SCM scm_real_p (SCM x);
SCM_API SCM scm_rational_p (SCM z);
SCM_API SCM scm_integer_p (SCM x);
SCM_API SCM scm_exact_integer_p (SCM x);
SCM_API SCM scm_inexact_p (SCM x);
SCM_API int scm_is_inexact (SCM x);
SCM_API SCM scm_num_eq_p (SCM x, SCM y);
@ -331,6 +332,7 @@ SCM_INTERNAL void scm_i_print_complex (double real, double imag, SCM port);
/* conversion functions for integers */
SCM_API int scm_is_integer (SCM val);
SCM_API int scm_is_exact_integer (SCM val);
SCM_API int scm_is_signed_integer (SCM val,
scm_t_intmax min, scm_t_intmax max);
SCM_API int scm_is_unsigned_integer (SCM val,