mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-04-30 03:40:34 +02:00
Build scm_integer_p on scm_is_integer, not vice versa
* libguile/numbers.c: Switch layering of scm_is_integer / scm_is_exact_integer and their SCM-valued counterparts.
This commit is contained in:
parent
24ce3cedfc
commit
ef5ade30f9
1 changed files with 11 additions and 15 deletions
|
@ -4605,15 +4605,7 @@ SCM_DEFINE (scm_integer_p, "integer?", 1, 0, 0,
|
|||
"else return @code{#f}.")
|
||||
#define FUNC_NAME s_scm_integer_p
|
||||
{
|
||||
if (SCM_I_INUMP (x) || SCM_BIGP (x))
|
||||
return SCM_BOOL_T;
|
||||
else if (SCM_REALP (x))
|
||||
{
|
||||
double val = SCM_REAL_VALUE (x);
|
||||
return scm_from_bool (!isinf (val) && (val == floor (val)));
|
||||
}
|
||||
else
|
||||
return SCM_BOOL_F;
|
||||
return scm_from_bool (scm_is_integer (x));
|
||||
}
|
||||
#undef FUNC_NAME
|
||||
|
||||
|
@ -4623,10 +4615,7 @@ SCM_DEFINE (scm_exact_integer_p, "exact-integer?", 1, 0, 0,
|
|||
"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;
|
||||
return scm_from_bool (scm_is_exact_integer (x));
|
||||
}
|
||||
#undef FUNC_NAME
|
||||
|
||||
|
@ -7716,13 +7705,20 @@ SCM_DEFINE (scm_rationalize, "rationalize", 2, 0, 0,
|
|||
int
|
||||
scm_is_integer (SCM val)
|
||||
{
|
||||
return scm_is_true (scm_integer_p (val));
|
||||
if (scm_is_exact_integer (val))
|
||||
return 1;
|
||||
if (SCM_REALP (val))
|
||||
{
|
||||
double x = SCM_REAL_VALUE (val);
|
||||
return !isinf (x) && (x == floor (x));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
scm_is_exact_integer (SCM val)
|
||||
{
|
||||
return scm_is_true (scm_exact_integer_p (val));
|
||||
return SCM_I_INUMP (val) || SCM_BIGP (val);
|
||||
}
|
||||
|
||||
int
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue