mirror of
https://github.com/justinethier/cyclone.git
synced 2025-07-14 08:17:35 +02:00
Added round, ceil, floor, truncate
This commit is contained in:
parent
4dc2e78ce8
commit
48e88d41a7
2 changed files with 26 additions and 0 deletions
|
@ -93,6 +93,16 @@ object Cyc_global_set(void *thd, object *glo, object value);
|
|||
} \
|
||||
return_closcall1(data, cont, &d)
|
||||
|
||||
#define return_exact_double_op(data, cont, OP, z) \
|
||||
make_int(i, 0); \
|
||||
Cyc_check_num(data, z); \
|
||||
if (type_of(z) == integer_tag) { \
|
||||
i.value = (int)OP(((integer_type *)z)->value); \
|
||||
} else { \
|
||||
i.value = (int)OP(((double_type *)z)->value); \
|
||||
} \
|
||||
return_closcall1(data, cont, &i)
|
||||
|
||||
/* Prototypes for primitive functions. */
|
||||
|
||||
extern object Cyc_global_variables;
|
||||
|
|
|
@ -92,6 +92,10 @@
|
|||
cond-expand
|
||||
when
|
||||
quasiquote
|
||||
floor
|
||||
ceiling
|
||||
truncate
|
||||
round
|
||||
)
|
||||
(begin
|
||||
;; Features implemented by this Scheme
|
||||
|
@ -648,4 +652,16 @@
|
|||
(else
|
||||
#f))))
|
||||
|
||||
(define-c floor
|
||||
"(void *data, int argc, closure _, object k, object z)"
|
||||
" return_exact_double_op(data, k, floor, z); ")
|
||||
(define-c ceiling
|
||||
"(void *data, int argc, closure _, object k, object z)"
|
||||
" return_exact_double_op(data, k, ceil, z); ")
|
||||
(define-c truncate
|
||||
"(void *data, int argc, closure _, object k, object z)"
|
||||
" return_exact_double_op(data, k, (int), z); ")
|
||||
(define-c round
|
||||
"(void *data, int argc, closure _, object k, object z)"
|
||||
" return_exact_double_op(data, k, round, z); ")
|
||||
))
|
||||
|
|
Loading…
Add table
Reference in a new issue