On Wed, Sep 12, 2012 at 8:11 AM, Jori Mantysalo <[email protected]> wrote: > On Wed, 12 Sep 2012, Dan Drake wrote: > >>> sage: 0.2 + 0.1 == 0.3 >>> False > > >> using an approximation -- and after the addition, the error is big >> enough to return False. > > > ?? Is there some kind of heuristics in equality testing in Sage?
No. > I would > have guessed that a==b only when they are equal to every bit. That's right. Sage just wraps mpfr for floating point arithmetic, and inherits its well-defined and rigorous semantics: http://www.mpfr.org/ William > > * * * > > At least in principle some systems might evaluate 0.2 as rational 1/5, maybe > with some heuristics, or have 'a==b' evaluated as '(a-b)/max(a,b) < > some_constant_here'. However, things would still broke with for example > series > > X_0=1 > X_1=1/3 > X_(n+1)=(13/3)*X_(n)-(4/3)*X_(n-1) > > -- > Jori Mäntysalo > > > -- > You received this message because you are subscribed to the Google Groups > "sage-support" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > Visit this group at http://groups.google.com/group/sage-support?hl=en. > > -- William Stein Professor of Mathematics University of Washington http://wstein.org -- You received this message because you are subscribed to the Google Groups "sage-support" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. Visit this group at http://groups.google.com/group/sage-support?hl=en.
