Skip to content

Commit d65a248

Browse files
committed
Printing negative zero in complex imag part in the right way.
1 parent 0190f59 commit d65a248

File tree

2 files changed

+3
-2
lines changed
  • graalpython
    • com.oracle.graal.python.test/src/tests/unittest_tags
    • com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/complex

2 files changed

+3
-2
lines changed

graalpython/com.oracle.graal.python.test/src/tests/unittest_tags/test_complex.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
*ComplexTest.test_getnewargs
77
*ComplexTest.test_neg
88
*ComplexTest.test_negated_imaginary_literal
9+
*ComplexTest.test_negative_zero_repr_str
910
*ComplexTest.test_overflow
1011
*ComplexTest.test_plus_minus_0j
1112
*ComplexTest.test_repr_str

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/complex/PComplex.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@ public double getImag() {
9191
@Override
9292
@TruffleBoundary
9393
public String toString() {
94-
if (Double.compare(real, 0.0) == 0) {
95-
return toString(imag) + "j";
94+
if (Double.compare(real, 0.0) == 0) {
95+
return Double.compare(imag, 0.0) >= 0 ? toString(imag) + "j" : String.format("-%sj", toString(-imag));
9696
} else {
9797
String realString = toString(real);
9898
if (real == 0.0) {

0 commit comments

Comments
 (0)