mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-16 08:40:19 +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:
parent
f659df4495
commit
900a897cd3
4 changed files with 72 additions and 4 deletions
|
@ -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)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue