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)])
(fx> b0 127)))
(define (inexact->exact x)
(define ($exact x who)
(import (ikarus system $compnums))
(cond
[(flonum? x)
(or ($flonum->exact x)
(die 'inexact->exact "no real value" x))]
[(or (fixnum? x) (ratnum? x) (bignum? x)) x]
[else
(die 'inexact->exact "not an inexact number" x)]))
(die who "number has no real value" x))]
[(cflonum? x)
(make-rectangular
(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)
(cond
[(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 (inexact->exact x) ($exact x 'inexact->exact))
(define (exact x) ($exact x 'exact))
(define (flpositive? x)

View File

@ -1 +1 @@
1755
1756