* string->number now understands +nan.0, -nan.0, +inf.0 and -inf.0.
This commit is contained in:
parent
277710d6d1
commit
ca2be2436a
BIN
src/ikarus.boot
BIN
src/ikarus.boot
Binary file not shown.
|
@ -2143,6 +2143,13 @@
|
||||||
(error 'string->number "~s is not a string" x))
|
(error 'string->number "~s is not a string" x))
|
||||||
(let ([n (string-length x)])
|
(let ([n (string-length x)])
|
||||||
(cond
|
(cond
|
||||||
|
[(fx= n (string-length "+xxx.0"))
|
||||||
|
(cond
|
||||||
|
[(string=? x "+inf.0") +inf.0]
|
||||||
|
[(string=? x "-inf.0") -inf.0]
|
||||||
|
[(string=? x "+nan.0") +nan.0]
|
||||||
|
[(string=? x "-nan.0") -nan.0]
|
||||||
|
[else (start x n 0 #f #f)])]
|
||||||
[(fx> n 0) (start x n 0 #f #f)]
|
[(fx> n 0) (start x n 0 #f #f)]
|
||||||
[else #f]))))
|
[else #f]))))
|
||||||
|
|
||||||
|
|
|
@ -664,10 +664,10 @@
|
||||||
(tokenize-decimal-no-digits p (cons c ls) #f)]
|
(tokenize-decimal-no-digits p (cons c ls) #f)]
|
||||||
[(char=? c #\i)
|
[(char=? c #\i)
|
||||||
(read-char* p (cons #\i ls) "nf.0" "number sequence")
|
(read-char* p (cons #\i ls) "nf.0" "number sequence")
|
||||||
(/ 1.0 0.0)]
|
+inf.0]
|
||||||
[(char=? c #\n)
|
[(char=? c #\n)
|
||||||
(read-char* p (cons #\i ls) "an.0" "number sequence")
|
(read-char* p (cons #\i ls) "an.0" "number sequence")
|
||||||
(/ (/ 1.0 0.0) (/ 1.0 0.0))]
|
+nan.0]
|
||||||
[else (num-error "invalid sequence" (cons c ls))])))
|
[else (num-error "invalid sequence" (cons c ls))])))
|
||||||
(define (tokenize-integer-no-digits p ls exact? radix?)
|
(define (tokenize-integer-no-digits p ls exact? radix?)
|
||||||
(let ([c (read-char p)])
|
(let ([c (read-char p)])
|
||||||
|
|
Loading…
Reference in New Issue