From: Chris Hanson Date: Wed, 2 May 2018 06:35:32 +0000 (-0700) Subject: Change printed representation of inf/nan to match R7RS. X-Git-Tag: mit-scheme-pucked-x11-0.3.1~7^2~84 X-Git-Url: https://birchwood-abbey.net/git?a=commitdiff_plain;h=6ada7103062ecec31a07fcd03567d3f84167c4b6;p=mit-scheme.git Change printed representation of inf/nan to match R7RS. --- diff --git a/src/runtime/dragon4.scm b/src/runtime/dragon4.scm index 35883f18b..14e13a5db 100644 --- a/src/runtime/dragon4.scm +++ b/src/runtime/dragon4.scm @@ -66,11 +66,7 @@ not much different to numbers within a few orders of magnitude of 1. unspecific) (define (flo:->string x radix) - (let ((inf? - (lambda (x) - (and (flo:> x 1.) - (flo:= x (flo:/ x 2.))))) - (x>0 + (let ((x>0 (lambda (x) (let ((p flo:significand-digits-base-2)) (call-with-values (lambda () (dragon4-normalize x p)) @@ -90,20 +86,21 @@ not much different to numbers within a few orders of magnitude of 1. (display-procedure digits k radix)))))))))))) (or (and flonum-unparser-hook (flonum-unparser-hook x radix)) - (cond ((flo:positive? x) - (if (inf? x) - (string-copy "#[+inf]") + (cond ((flo:nan? x) + (string-copy "+nan.0")) + ((flo:positive? x) + (if (flo:inf? x) + (string-copy "+inf.0") (x>0 x))) ((flo:negative? x) (let ((x (flo:negate x))) - (if (inf? x) - (string-copy "#[-inf]") + (if (flo:inf? x) + (string-copy "-inf.0") (string-append "-" (x>0 x))))) ((flo:zero? x) - ;; XXX Kludgey test for zero sign. - (string-copy (if (flo:negative? (flo:atan2 x -1.)) "-0." "0."))) + (string-copy (if (flo:safe-negative? x) "-0." "0."))) (else - (string-copy "#[NaN]")))))) + (string-copy "+nan.0")))))) (define (flonum-unparser:normal-output digits k radix) (let ((k+1 (+ k 1)))