From: Taylor R Campbell Date: Fri, 16 Nov 2018 16:38:36 +0000 (+0000) Subject: Don't add the #x marker in flo:->string / number->string. X-Git-Tag: mit-scheme-pucked-10.1.2~16^2~73 X-Git-Url: https://birchwood-abbey.net/git?a=commitdiff_plain;h=e27d2802fcf0302e30d028c62609f41336a20de5;p=mit-scheme.git Don't add the #x marker in flo:->string / number->string. We'll add it in the printer downstream. --- diff --git a/src/runtime/dragon4.scm b/src/runtime/dragon4.scm index 73c69a9b9..28a170cef 100644 --- a/src/runtime/dragon4.scm +++ b/src/runtime/dragon4.scm @@ -66,44 +66,44 @@ not much different to numbers within a few orders of magnitude of 1. unspecific) (define (flo:->string x radix) - (define (x>0 x signify) - (let ((p flo:significand-digits-base-2)) - (call-with-values flonum-printer-cutoff-args - (lambda (cutoff-mode cutoff display-procedure) - (if (int:= radix #x10) - (string-append "#x" (signify (ieee754-binary64-hex-string x ""))) - (signify - (call-with-values (lambda () (dragon4-normalize x p)) - (lambda (f e) - (dragon4 f e p radix cutoff-mode cutoff - (lambda (u k generate) - (let ((digits - (list->string - (let loop - ((u u) (k k) (generate generate)) - k ;ignore - (if (negative? u) - '() - (cons (digit->char u radix) - (generate loop))))))) - (display-procedure digits k radix)))))))))))) - (or (and flonum-printer-hook - (flonum-printer-hook x radix)) - (cond ((flo:nan? x) - (string-copy "+nan.0")) - ((flo:positive? x) - (if (flo:infinite? x) - (string-copy "+inf.0") - (x>0 x (lambda (s) s)))) - ((flo:negative? x) - (let ((x (flo:negate x))) + (let ((x>0 + (lambda (x) + (let ((p flo:significand-digits-base-2)) + (call-with-values flonum-printer-cutoff-args + (lambda (cutoff-mode cutoff display-procedure) + (if (int:= radix #x10) + (ieee754-binary64-hex-string x "") + (call-with-values (lambda () (dragon4-normalize x p)) + (lambda (f e) + (dragon4 f e p radix cutoff-mode cutoff + (lambda (u k generate) + (let ((digits + (list->string + (let loop + ((u u) (k k) (generate generate)) + k ;ignore + (if (negative? u) + '() + (cons (digit->char u radix) + (generate loop))))))) + (display-procedure digits k radix))))))))))))) + (or (and flonum-printer-hook + (flonum-printer-hook x radix)) + (cond ((flo:nan? x) + (string-copy "+nan.0")) + ((flo:positive? x) (if (flo:infinite? x) - (string-copy "-inf.0") - (x>0 x (lambda (s) (string-append "-" s)))))) - ((flo:zero? x) - (string-copy (if (flo:safe-negative? x) "-0." "0."))) - (else - (string-copy "+nan.0"))))) + (string-copy "+inf.0") + (x>0 x))) + ((flo:negative? x) + (let ((x (flo:negate x))) + (if (flo:infinite? x) + (string-copy "-inf.0") + (string-append "-" (x>0 x))))) + ((flo:zero? x) + (string-copy (if (flo:safe-negative? x) "-0." "0."))) + (else + (string-copy "+nan.0")))))) (define (flonum-printer:normal-output digits k radix) (let ((k+1 (+ k 1))) diff --git a/tests/runtime/test-dragon4.scm b/tests/runtime/test-dragon4.scm index 83bd9c967..1890ed0ac 100644 --- a/tests/runtime/test-dragon4.scm +++ b/tests/runtime/test-dragon4.scm @@ -94,9 +94,9 @@ USA. (define-hex-tests 'hex '(0. "0.") '(-0. "-0.") - '(1. "#x1p+0") - '(-1. "#x-1p+0") - '(1.5 "#x1.8p+0") - '(-1.5 "#x-1.8p+0") - '(15. "#x1.ep+3") - '(16. "#x1p+4")) \ No newline at end of file + '(1. "1p+0") + '(-1. "-1p+0") + '(1.5 "1.8p+0") + '(-1.5 "-1.8p+0") + '(15. "1.ep+3") + '(16. "1p+4")) \ No newline at end of file