mirror of
https://github.com/justinethier/cyclone.git
synced 2025-05-19 05:39:17 +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)"
|
"(void *data, int argc, closure _, object k, object n)"
|
||||||
" Cyc_get_ratio(data, k, n, 0);")
|
" Cyc_get_ratio(data, k, n, 0);")
|
||||||
|
|
||||||
;; TODO: integrate into quotient?
|
(define-c fixnum?
|
||||||
(define-c fixnum?
|
"(void *data, int argc, closure _, object k, object obj)"
|
||||||
"(void *data, int argc, closure _, object k, object obj)"
|
" return_closcall1(data, k,
|
||||||
" return_closcall1(data, k,
|
obj_is_int(obj) ? boolean_t : boolean_f); "
|
||||||
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)
|
(define (quotient x y)
|
||||||
;; TODO: if x and y are fixnums, do fast divide and return a fixnum
|
(if (and (fixnum? x) (fixnum? y))
|
||||||
;; TODO: above good enough or are there special cases??
|
(exact (truncate (/ x y)))
|
||||||
(truncate (/ x y)))
|
(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))))
|
|
||||||
|
|
||||||
(define truncate-quotient quotient)
|
(define truncate-quotient quotient)
|
||||||
(define truncate-remainder remainder)
|
(define truncate-remainder remainder)
|
||||||
|
|
Loading…
Add table
Reference in a new issue