mirror of
https://github.com/RustPython/RustPython.git
synced 2026-06-09 22:49:57 +09:00
Merge pull request #1384 from tsvankay/float_repr
Fix __repr__ return value for -0.0
This commit is contained in:
@@ -198,6 +198,7 @@ assert_raises(ValueError, float('nan').as_integer_ratio)
|
||||
|
||||
assert str(1.0) == '1.0'
|
||||
assert str(0.0) == '0.0'
|
||||
assert str(-0.0) == '-0.0'
|
||||
assert str(1.123456789) == '1.123456789'
|
||||
|
||||
# Test special case for lexer, float starts with a dot:
|
||||
|
||||
@@ -411,7 +411,7 @@ impl PyFloat {
|
||||
#[pymethod(name = "__repr__")]
|
||||
fn repr(&self, vm: &VirtualMachine) -> String {
|
||||
if self.is_integer(vm) {
|
||||
format!("{:.1}", self.value)
|
||||
format!("{:.1?}", self.value)
|
||||
} else {
|
||||
self.value.to_string()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user