* Added inexact->exact
This commit is contained in:
parent
0480517615
commit
d88126aea1
BIN
src/ikarus.boot
BIN
src/ikarus.boot
Binary file not shown.
|
@ -5,11 +5,12 @@
|
||||||
|
|
||||||
|
|
||||||
(library (ikarus flonums)
|
(library (ikarus flonums)
|
||||||
(export string->flonum flonum->string $flonum->exact)
|
(export string->flonum flonum->string $flonum->exact
|
||||||
|
inexact->exact)
|
||||||
(import
|
(import
|
||||||
(ikarus system $bytevectors)
|
(ikarus system $bytevectors)
|
||||||
(ikarus system $flonums)
|
(ikarus system $flonums)
|
||||||
(except (ikarus) flonum->string string->flonum))
|
(except (ikarus) flonum->string string->flonum inexact->exact))
|
||||||
|
|
||||||
(define (flonum->string x)
|
(define (flonum->string x)
|
||||||
(utf8-bytevector->string
|
(utf8-bytevector->string
|
||||||
|
@ -64,6 +65,15 @@
|
||||||
(* m (expt 2 -1074)))]
|
(* m (expt 2 -1074)))]
|
||||||
[else #f])))
|
[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)]))
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -399,6 +399,7 @@
|
||||||
[ceiling i r]
|
[ceiling i r]
|
||||||
[exact-integer-sqrt i r]
|
[exact-integer-sqrt i r]
|
||||||
[exact->inexact i r]
|
[exact->inexact i r]
|
||||||
|
[inexact->exact i r]
|
||||||
[symbol? i r symbols]
|
[symbol? i r symbols]
|
||||||
[gensym? i symbols]
|
[gensym? i symbols]
|
||||||
[gensym i symbols]
|
[gensym i symbols]
|
||||||
|
|
Loading…
Reference in New Issue