summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
d95486b)
Does what 'quotient' did before, now quotient rounds towards zero
while floor-quotient rounds down.
Signed-off-by: Keith Packard <keithp@keithp.com>
case builtin_quotient:
if (c == 0)
return ao_scheme_error(AO_SCHEME_DIVIDE_BY_ZERO, "quotient by zero");
case builtin_quotient:
if (c == 0)
return ao_scheme_error(AO_SCHEME_DIVIDE_BY_ZERO, "quotient by zero");
+ r = r / c;
+ break;
+ case builtin_floor_quotient:
+ if (c == 0)
+ return ao_scheme_error(AO_SCHEME_DIVIDE_BY_ZERO, "floor-quotient by zero");
if (r % c != 0 && (c < 0) != (r < 0))
r = r / c - 1;
else
if (r % c != 0 && (c < 0) != (r < 0))
r = r / c - 1;
else
r /= c;
break;
case builtin_quotient:
r /= c;
break;
case builtin_quotient:
+ case builtin_floor_quotient:
case builtin_remainder:
case builtin_modulo:
return ao_scheme_error(AO_SCHEME_INVALID, "non-integer value in integer divide");
case builtin_remainder:
case builtin_modulo:
return ao_scheme_error(AO_SCHEME_INVALID, "non-integer value in integer divide");
return ao_scheme_math(cons, builtin_quotient);
}
return ao_scheme_math(cons, builtin_quotient);
}
+ao_poly
+ao_scheme_do_floor_quotient(struct ao_scheme_cons *cons)
+{
+ return ao_scheme_math(cons, builtin_floor_quotient);
+}
+
ao_poly
ao_scheme_do_modulo(struct ao_scheme_cons *cons)
{
ao_poly
ao_scheme_do_modulo(struct ao_scheme_cons *cons)
{
all f_lambda modulo modulo %
all f_lambda remainder
all f_lambda quotient
all f_lambda modulo modulo %
all f_lambda remainder
all f_lambda quotient
+all f_lambda floor_quotient floor-quotient
all f_lambda equal = eq? eqv?
all f_lambda less < string<?
all f_lambda greater > string>?
all f_lambda equal = eq? eqv?
all f_lambda less < string<?
all f_lambda greater > string>?