mirror of
https://github.com/justinethier/cyclone.git
synced 2025-05-19 13:49:16 +02:00
Issue #303 - Handle numeric predicate edge cases
Add edge cases to (real?) for complex numbers, and (integer?) for reals.
This commit is contained in:
parent
5f0fa5eeea
commit
204e31e362
1 changed files with 11 additions and 3 deletions
12
runtime.c
12
runtime.c
|
@ -1671,7 +1671,14 @@ object Cyc_is_number(object o)
|
|||
|
||||
object Cyc_is_real(object o)
|
||||
{
|
||||
return Cyc_is_number(o);
|
||||
if ((o != NULL) && (obj_is_int(o) ||
|
||||
(!is_value_type(o) && (type_of(o) == integer_tag
|
||||
|| type_of(o) == bignum_tag
|
||||
|| type_of(o) == double_tag
|
||||
|| (type_of(o) == complex_num_tag &&
|
||||
cimag(complex_num_value(o)) == 0.0))))) // Per R7RS
|
||||
return boolean_t;
|
||||
return boolean_f;
|
||||
}
|
||||
|
||||
object Cyc_is_complex(object o)
|
||||
|
@ -1692,7 +1699,8 @@ object Cyc_is_integer(object o)
|
|||
{
|
||||
if ((o != NULL) && (obj_is_int(o) ||
|
||||
(!is_value_type(o) && type_of(o) == integer_tag) ||
|
||||
(!is_value_type(o) && type_of(o) == bignum_tag)))
|
||||
(!is_value_type(o) && type_of(o) == bignum_tag) ||
|
||||
(!is_value_type(o) && type_of(o) == double_tag && double_value(o) == round(double_value(o))))) // Per R7RS
|
||||
return boolean_t;
|
||||
return boolean_f;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue