mirror of
https://github.com/justinethier/cyclone.git
synced 2025-05-25 13:05:05 +02:00
Use Cyc_remainder
This commit is contained in:
parent
af055ea80c
commit
3f7753149e
1 changed files with 1 additions and 17 deletions
|
@ -1058,23 +1058,7 @@
|
||||||
;; Apparently C % is actually the remainder, not modulus
|
;; Apparently C % is actually the remainder, not modulus
|
||||||
(define-c remainder
|
(define-c remainder
|
||||||
"(void *data, int argc, closure _, object k, object num1, object num2)"
|
"(void *data, int argc, closure _, object k, object num1, object num2)"
|
||||||
" int i, j;
|
" Cyc_remainder(data, k, num1, num2); ")
|
||||||
Cyc_check_num(data, num1);
|
|
||||||
Cyc_check_num(data, num2);
|
|
||||||
if (obj_is_int(num1)) {
|
|
||||||
i = obj_obj2int(num1);
|
|
||||||
} else /* Must be double: if (type_of(num1) == double_tag)*/ {
|
|
||||||
i = ((double_type *)num1)->value;
|
|
||||||
}
|
|
||||||
if (obj_is_int(num2)) {
|
|
||||||
j = obj_obj2int(num2);
|
|
||||||
} else /* Must be double: if (type_of(num2) == double_tag)*/ {
|
|
||||||
j = ((double_type *)num2)->value;
|
|
||||||
}
|
|
||||||
{
|
|
||||||
object result = obj_int2obj(i % j);
|
|
||||||
return_closcall1(data, k, result);
|
|
||||||
}")
|
|
||||||
;; From chibi scheme. Cannot use C % operator
|
;; From chibi scheme. Cannot use C % operator
|
||||||
(define (modulo a b)
|
(define (modulo a b)
|
||||||
(let ((res (remainder a b)))
|
(let ((res (remainder a b)))
|
||||||
|
|
Loading…
Add table
Reference in a new issue