mirror of
https://github.com/RustPython/RustPython.git
synced 2026-10-28 18:59:04 +08:00
Merge pull request #1076 from corona10/complex_repr
Fix complex representation for negative imaginary number case.
This commit is contained in:
2 files changed
+7
-1
No files matched your search
@@ -135,3 +135,9 @@ msg = 'int too large to convert to float'
|
||||
assert_raises(OverflowError, lambda: complex(10 ** 1000, 0), msg)
|
||||
assert_raises(OverflowError, lambda: complex(0, 10 ** 1000), msg)
|
||||
assert_raises(OverflowError, lambda: 0j + 10 ** 1000, msg)
|
||||
|
||||
# str/repr
|
||||
assert '(1+1j)' == str(1+1j)
|
||||
assert '(1-1j)' == str(1-1j)
|
||||
assert '(1+1j)' == repr(1+1j)
|
||||
assert '(1-1j)' == repr(1-1j)
|
||||
@@ -204,7 +204,7 @@ impl PyComplex {
|
||||
if re == 0.0 {
|
||||
format!("{}j", im)
|
||||
} else {
|
||||
format!("({}+{}j)", re, im)
|
||||
format!("({}{:+}j)", re, im)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user