inexact->exact and exact now hangle compnums and cflonums properly.

This commit is contained in:
Abdulaziz Ghuloum 2009-04-06 17:41:28 +03:00
parent 65dc2bc40d
commit 3aad0fbe0b
2 changed files with 14 additions and 18 deletions

View File

@ -257,27 +257,23 @@
(let ([b0 ($flonum-u8-ref x 0)]) (let ([b0 ($flonum-u8-ref x 0)])
(fx> b0 127))) (fx> b0 127)))
(define ($exact x who)
(import (ikarus system $compnums))
(define (inexact->exact x)
(cond (cond
[(flonum? x) [(flonum? x)
(or ($flonum->exact x) (or ($flonum->exact x)
(die 'inexact->exact "no real value" x))] (die who "number has no real value" x))]
[(or (fixnum? x) (ratnum? x) (bignum? x)) x] [(cflonum? x)
[else (make-rectangular
(die 'inexact->exact "not an inexact number" x)])) (or ($flonum->exact ($cflonum-real x))
(die who "number has no real value" x))
(or ($flonum->exact ($cflonum-imag x))
(die who "number has no real value" x)))]
[(or (fixnum? x) (ratnum? x) (bignum? x) (compnum? x)) x]
[else (die who "not a number" x)]))
(define (exact x) (define (inexact->exact x) ($exact x 'inexact->exact))
(cond (define (exact x) ($exact x 'exact))
[(flonum? x)
(or ($flonum->exact x)
(die 'exact "no real value" x))]
[(or (fixnum? x) (ratnum? x) (bignum? x)) x]
[else
(die 'exact "not an inexact number" x)]))
(define (flpositive? x) (define (flpositive? x)

View File

@ -1 +1 @@
1755 1756