Next: debugging, Previous: flonum format, Up: Top [Index]
The following bindings are exported by the library (vicare
numerics flonum-parser).
Parse the flonum its components for string formatting.
If flonum is representable as real number, apply the function real-func to 3 arguments: a boolean, true if flonum is positive; a list of characters representing the digits of flonum; a fixnum representing the exponent of flonum. Return the result of the application.
If flonum is not representable as real number, apply the function unreal-func to a single argument being the string representation of flonum. Return the result of the application.
Notice how the arguments handed to real-func match the argument of
format-flonum from (vicare flonum-formatter).
#!r6rs
(import (vicare)
(vicare numerics flonum-parser))
(parse-flonum 1.23456789
(lambda args (cons 'real args))
(lambda args (cons 'unreal args)))
⇒ (real #t
(#\1 #\2 #\3 #\4 #\5 #\6 #\7 #\8 #\9
#\0 #\0 #\0 #\0 #\0 #\0 #\0 #\1)
1)
(parse-flonum 12.34e5
(lambda args (cons 'real args))
(lambda args (cons 'unreal args)))
⇒ (real #t (#\1 #\2 #\3 #\4) 7)
(parse-flonum -12.34e5
(lambda args (cons 'real args))
(lambda args (cons 'unreal args)))
⇒ (real #f (#\1 #\2 #\3 #\4) 7)
(parse-flonum +inf.0
(lambda args (cons 'real args))
(lambda args (cons 'unreal args)))
⇒ (unreal "+inf.0")
(parse-flonum +nan.0
(lambda args (cons 'real args))
(lambda args (cons 'unreal args)))
⇒ (unreal "+nan.0")