Work on exception handling, especially around ratio arithmetic

Much simplified but will break things!
This commit is contained in:
Simon Brooke 2021-07-25 17:02:28 +01:00
parent d2101dbd47
commit 70d176982b
No known key found for this signature in database
GPG key ID: A7A4F18D1D4DF987
14 changed files with 298 additions and 258 deletions

View file

@ -390,3 +390,38 @@ struct cons_pointer integer_to_string( struct cons_pointer int_pointer,
return result;
}
/**
* true if a and be are both integers whose value is the same value.
*/
bool equal_integer_integer(struct cons_pointer a, struct cons_pointer b) {
bool result = false;
if (integerp(a) && integerp(b)){
struct cons_space_object *cell_a = &pointer2cell( a );
struct cons_space_object *cell_b = &pointer2cell( b );
result = cell_a->payload.integer.value == cell_b->payload.integer.value;
}
return result;
}
/**
* true if `a` is an integer, and `b` is a real number whose value is the
* value of that integer.
*/
bool equal_integer_real(struct cons_pointer a, struct cons_pointer b) {
bool result = false;
if (integerp(a) && realp(b))
{
long double bv = pointer2cell(b).payload.real.value;
if (floor(bv) == bv) {
result = pointer2cell(a).payload.integer.value == (int64_t)bv;
}
}
return result;
}