From 313b951ff0eed638bd3350c3790a8ec65a16c218 Mon Sep 17 00:00:00 2001 From: Taylor R Campbell Date: Sun, 18 Nov 2018 04:09:23 +0000 Subject: [PATCH] Fix printing signed zero imaginary part. --- src/runtime/arith.scm | 5 +++++ tests/runtime/test-readwrite.scm | 6 +++--- 2 files changed, 8 insertions(+), 3 deletions(-) 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) -- 2.25.1