Comment #7 on issue 2107 by [email protected]: Real(0.1, 10) - Real(0.1, 10) -> 3.637923296e-13
http://code.google.com/p/sympy/issues/detail?id=2107

This issue is really peculiar. Currently in master I get:

In [1]: a = Float(0.1, 10)

In [2]: b = Float("0.1", 10) # <- note the quotes

In [3]: a - a            # this is equivalent to Add(a, -a)
Out[3]: 3.637923296e-13  # because Number doesn't implement __sub__
# in infinities branch I added __sub__ and there it gives 0

In [4]: b - b            # but with quotes it works
Out[4]: 0

In [5]: a + (-a)         # this uses Float.__add__ directly
Out[5]: 0

In [6]: b + (-b)
Out[6]: 0

In [8]: Add(a, -a)
Out[8]: 3.637923296e-13

In [9]: Add(b, -b)
Out[9]: 0

In [10]: S.Zero + a + (-a) # this is the interesting part
Out[10]: 3.637923296e-13   # adding S.Zero makes a difference

In [11]: a + (-a)
Out[11]: 0

In [12]: S.Zero + b + (-b) # but not with quotes
Out[12]: 0

I think that the problem is with precision tracking (but then why version with quotes work -> does this use different implementation?).

--
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.

Reply via email to