* string->number now understands +nan.0, -nan.0, +inf.0 and -inf.0.

This commit is contained in:
Abdulaziz Ghuloum 2007-09-11 03:13:28 -04:00
parent 277710d6d1
commit ca2be2436a
3 changed files with 9 additions and 2 deletions

Binary file not shown.

View File

@ -2143,6 +2143,13 @@
(error 'string->number "~s is not a string" x))
(let ([n (string-length x)])
(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)]
[else #f]))))

View File

@ -664,10 +664,10 @@
(tokenize-decimal-no-digits p (cons c ls) #f)]
[(char=? c #\i)
(read-char* p (cons #\i ls) "nf.0" "number sequence")
(/ 1.0 0.0)]
+inf.0]
[(char=? c #\n)
(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))])))
(define (tokenize-integer-no-digits p ls exact? radix?)
(let ([c (read-char p)])