Status: Accepted
Owner: ----
Labels: Type-Defect Priority-Medium
New issue 3066 by [email protected]: int(expression) should not raise an
error
http://code.google.com/p/sympy/issues/detail?id=3066
e=Add(1,Float('.99999999999999999999999999',''),evaluate=0)
int(e)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "sympy\core\expr.py", line 169, in __int__
of decimal places, first.''' % (self, i)))
ValueError:
1 + 0.99999999999999999999999999 was calculated to 15 decimal digits
and appeared to be 2; it was not confirmed to be an integer, however.
Use round() to round your expression to the desired number of decimal
places, first.
(e-2).n()
-1.e-26
By subtracting the integer candidate for e from e and checking the sign,
one can tell if the candidate is 1 too large, so it should always be
possible to return the correct int value, I believe.
--
You received this message because you are subscribed to the Google Groups
"sympy-issues" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sympy-issues?hl=en.