Fix printing signed zero imaginary part.
authorTaylor R Campbell <campbell@mumble.net>
Sun, 18 Nov 2018 04:09:23 +0000 (04:09 +0000)
committerTaylor R Campbell <campbell@mumble.net>
Sun, 18 Nov 2018 06:11:43 +0000 (06:11 +0000)
src/runtime/arith.scm
tests/runtime/test-readwrite.scm

index e5409c8cd15e36982183056bd7767d3f9eddf76a..ffbf8cb08b843bcbad28ac1504642b674bcd3278 100644 (file)
@@ -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"))
index 86575759ac2316b3175e0e4c8d18549a30be272b..792f74a62f0043bf8522d69da3ecd283ca135445 100644 (file)
@@ -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)