* Added inexact->exact

This commit is contained in:
Abdulaziz Ghuloum 2007-06-10 07:35:39 +03:00
parent 0480517615
commit d88126aea1
3 changed files with 13 additions and 2 deletions

Binary file not shown.

View File

@ -5,11 +5,12 @@
(library (ikarus flonums)
(export string->flonum flonum->string $flonum->exact)
(export string->flonum flonum->string $flonum->exact
inexact->exact)
(import
(ikarus system $bytevectors)
(ikarus system $flonums)
(except (ikarus) flonum->string string->flonum))
(except (ikarus) flonum->string string->flonum inexact->exact))
(define (flonum->string x)
(utf8-bytevector->string
@ -64,6 +65,15 @@
(* m (expt 2 -1074)))]
[else #f])))
(define (inexact->exact x)
(cond
[(flonum? x)
(or ($flonum->exact x)
(error 'inexact->exact "~s has no real value" x))]
[(or (fixnum? x) (ratnum? x) (bignum? x)) x]
[else
(error 'inexact->exact "~s is not an inexact number" x)]))
)

View File

@ -399,6 +399,7 @@
[ceiling i r]
[exact-integer-sqrt i r]
[exact->inexact i r]
[inexact->exact i r]
[symbol? i r symbols]
[gensym? i symbols]
[gensym i symbols]