Skip to content

Change repr(float) if float(int(f)) == f #104

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from Sep 30, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Update float.py
  • Loading branch information
Tim-St committed Sep 29, 2019
commit 95ae69d53bcdffb27a0265a8060aaac475506324
14 changes: 13 additions & 1 deletion py/tests/float.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
assert float("-1E9") == -1E9
assert float("1E400") == float("inf")
assert float(" -1E400") == float("-inf")
assertRaises(ValueError, float, "1 E200")

doc="repr"
assert repr(float("1.0")) == "1.0"
assert repr(float("1.")) == "1.0"
assert repr(float("1.1")) == "1.1"
Expand All @@ -20,6 +23,15 @@
assert repr(float("1.00101")) == "1.00101"
assert repr(float("1.00")) == "1.0"
assert repr(float("2.010")) == "2.01"
assertRaises(ValueError, float, "1 E200")

doc="str"
assert str(float("1.0")) == "1.0"
assert str(float("1.")) == "1.0"
assert str(float("1.1")) == "1.1"
assert str(float("1.11")) == "1.11"
assert str(float("-1.0")) == "-1.0"
assert str(float("1.00101")) == "1.00101"
assert str(float("1.00")) == "1.0"
assert str(float("2.010")) == "2.01"

doc="finished"