There is no exact infinity or exact NaN.
sign))
((and (char-ci=? #\i char)
(string-prefix-ci? "nf.0" string start end))
- (parse-complex string (+ start 4) end
- (if (eq? #\- sign) (flo:-inf.0) (flo:+inf.0))
- exactness radix sign))
+ (and (not (eq? exactness 'exact))
+ (parse-complex string (+ start 4) end
+ (if (eq? #\- sign)
+ (flo:-inf.0)
+ (flo:+inf.0))
+ exactness radix sign)))
((and (char-ci=? #\n char)
(string-prefix-ci? "an." string start end))
(parse-nan-payload string (+ start 3) end exactness radix
(define (parse-nan-payload string start end exactness radix quiet? sign)
(let loop ((payload 0) (start start))
- (define (finish)
+ (define (finish-nan)
(and (or quiet? (not (zero? payload)))
- (apply-sign sign (flo:make-nan #f quiet? payload))))
+ (not (eq? exactness 'exact))
+ (flo:make-nan (if (eq? sign #\-) #t #f) quiet? payload)))
(if (fix:< start end)
(let ((char (string-ref string start)))
(cond ((char->digit char radix)
=> (lambda (digit)
(loop (+ (* payload radix) digit) (fix:+ start 1))))
- ((finish)
+ ((finish-nan)
=> (lambda (nan)
(parse-complex string start end nan
exactness radix sign)))
(else #f)))
- (finish))))
+ (finish-nan))))
(define (finish-integer integer exactness sign)
;; State: result is integer, apply exactness and sign.
(define-eqv-test "#i+inf.0" (flo:+inf.0))
(define-eqv-test "#i-inf.0" (flo:-inf.0))
-(define-error-test "#e+nan.0" expect-failure)
-(define-error-test "#e-nan.0" expect-failure)
+(define-error-test "#e+nan.0")
+(define-error-test "#e-nan.0")
(define-error-test "#e+snan.0") ;correctly errors by accident
(define-error-test "#e-snan.0")
-(define-error-test "#e+inf.0" expect-failure)
-(define-error-test "#e-inf.0" expect-failure)
+(define-error-test "#e+inf.0")
+(define-error-test "#e-inf.0")
(define-error-test "+0+0" expect-failure)
(define-error-test "0+0" expect-failure)
("-snan.deadbeef" ,expect-failure)
("#i+snan.0")
("#i-snan.0")
- ("#e+nan.0" ,expect-failure)
- ("#e-nan.0" ,expect-failure)
- ("#e+nan.1" ,expect-failure)
- ("#e-nan.1" ,expect-failure)
- ("#e+nan.123" ,expect-failure)
- ("#e-nan.123" ,expect-failure)
+ ("#e+nan.0")
+ ("#e-nan.0")
+ ("#e+nan.1")
+ ("#e-nan.1")
+ ("#e+nan.123")
+ ("#e-nan.123")
("#e+nan.deadbeef")
("#e-nan.deadbeef")
- ("#e+snan.1" ,expect-failure)
- ("#e-snan.1" ,expect-failure)
- ("#e+snan.123" ,expect-failure)
- ("#e-snan.123" ,expect-failure)
+ ("#e+snan.1")
+ ("#e-snan.1")
+ ("#e+snan.123")
+ ("#e-snan.123")
("#e+snan.deadbeef")
("#e-snan.deadbeef")
- ("#e+inf.0" ,expect-failure)
- ("#e-inf.0" ,expect-failure)
+ ("#e+inf.0")
+ ("#e-inf.0")
("+inf.0+snan.0i" ,expect-failure)
("+snan.0+inf.0i" ,expect-failure)
("+inf.0-snan.0i" ,expect-failure)