Skip to content

Commit

Permalink
Merge pull request #1176 from smichr/3815
Browse files Browse the repository at this point in the history
3185: watch for evaluated zero in round
  • Loading branch information
Tom Bachmann committed Mar 28, 2012
2 parents 023f517 + 425676f commit b08aa6b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
2 changes: 2 additions & 0 deletions sympy/core/expr.py
Original file line number Diff line number Diff line change
Expand Up @@ -2779,6 +2779,8 @@ def round(self, p=0):
dps = prec_to_dps(max(precs)) if precs else None

xpos = abs(x.n())
if not xpos:
return S.Zero
try:
mag_first_dig = int(ceil(log10(xpos)))
except (ValueError, OverflowError):
Expand Down
3 changes: 3 additions & 0 deletions sympy/core/tests/test_expr.py
Original file line number Diff line number Diff line change
Expand Up @@ -1346,3 +1346,6 @@ def test_round():
assert str((pi/10 + E*I).round(2)) == '0.31 + 2.72*I'
assert (pi/10 + E*I).round(2).as_real_imag() == (0.31, 2.72)
assert (pi/10 + E*I).round(2) == Float(0.31, 2) + I*Float(2.72, 3)

# issue 3815
assert (I**(I+3)).round(3) == Float('-0.208','')*I

0 comments on commit b08aa6b

Please sign in to comment.