mirror of
https://github.com/justinethier/cyclone.git
synced 2025-05-18 21:29:18 +02:00
Issue #519 - Allow truncate-quotient to return fixnums
Return a fixnum when fixnum args are received, per R7RS.
This commit is contained in:
parent
1a0f42386b
commit
43923a6e44
1 changed files with 9 additions and 13 deletions
|
@ -1525,21 +1525,17 @@
|
|||
"(void *data, int argc, closure _, object k, object n)"
|
||||
" Cyc_get_ratio(data, k, n, 0);")
|
||||
|
||||
;; TODO: integrate into quotient?
|
||||
(define-c fixnum?
|
||||
"(void *data, int argc, closure _, object k, object obj)"
|
||||
" return_closcall1(data, k,
|
||||
obj_is_int(obj) ? boolean_t : boolean_f); ")
|
||||
(define-c fixnum?
|
||||
"(void *data, int argc, closure _, object k, object obj)"
|
||||
" return_closcall1(data, k,
|
||||
obj_is_int(obj) ? boolean_t : boolean_f); "
|
||||
"(void *data, object ptr, object obj)"
|
||||
" return obj_is_int(obj) ? boolean_t : boolean_f; ")
|
||||
|
||||
(define (quotient x y)
|
||||
;; TODO: if x and y are fixnums, do fast divide and return a fixnum
|
||||
;; TODO: above good enough or are there special cases??
|
||||
(truncate (/ x y)))
|
||||
;; TODO: something like this, but do we want inline?
|
||||
;;(let ((result (/ x y)))
|
||||
;; (if (and (fixnum? x) (fixnum? y))
|
||||
;; (exact (truncate result))
|
||||
;; (truncate result))))
|
||||
(if (and (fixnum? x) (fixnum? y))
|
||||
(exact (truncate (/ x y)))
|
||||
(truncate (/ x y))))
|
||||
|
||||
(define truncate-quotient quotient)
|
||||
(define truncate-remainder remainder)
|
||||
|
|
Loading…
Add table
Reference in a new issue