From: Taylor R Campbell Date: Sun, 18 Nov 2018 04:09:23 +0000 (+0000) Subject: Fix printing signed zero imaginary part. X-Git-Tag: mit-scheme-pucked-10.1.2~16^2~31 X-Git-Url: https://birchwood-abbey.net/git?a=commitdiff_plain;h=313b951ff0eed638bd3350c3790a8ec65a16c218;p=mit-scheme.git Fix printing signed zero imaginary part. --- diff --git a/src/runtime/arith.scm b/src/runtime/arith.scm index e5409c8cd..ffbf8cb08 100644 --- a/src/runtime/arith.scm +++ b/src/runtime/arith.scm @@ -1977,6 +1977,11 @@ USA. (real:->string i radix)) ((real:negative? i) (string-append "-" (positive-case (real:negate i)))) + ((and (flo:flonum? i) + (flo:zero? i) + (flo:negative? (flo:copysign 1. i))) + ;; Not negative, but positive case gives `+-0.'. + "-0.") (else (string-append "+" (positive-case i))))) (if imaginary-unit-j? "j" "i")) diff --git a/tests/runtime/test-readwrite.scm b/tests/runtime/test-readwrite.scm index 86575759a..792f74a62 100644 --- a/tests/runtime/test-readwrite.scm +++ b/tests/runtime/test-readwrite.scm @@ -93,9 +93,9 @@ USA. ("123" ,assert-exact-integer) ("1/34" ,assert-exact-rational) ("123+456i" ,assert-complex-nonreal) - ("-0.i" ,assert-real xfail) ;real? - ("0.-0.i" ,assert-real xfail) ;real? - ("-0.-0.i" ,assert-real xfail) ;real? + ("-0.i" ,assert-real) ;real? + ("0.-0.i" ,assert-real) ;real? + ("-0.-0.i" ,assert-real) ;real? ("1.23" ,assert-flonum) ("+inf.0i" ,assert-complex-nonreal) ("-inf.0i" ,assert-complex-nonreal)