Differences between revisions 1 and 2
Revision 1 as of 2012-02-16 16:27:21
Size: 630
Editor: hivertwiki
Comment:
Revision 2 as of 2012-02-16 16:30:13
Size: 716
Editor: hivertwiki
Comment:
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
{{{#!rst
Line 4: Line 6:
The goal of this page is to gather all problems due to equality accepting coercion in borderline cases The goal of this page is to gather all problems due to equality accepting coercion in borderline cases::
Line 6: Line 8:
{{{
sage: bool(pi == 3.14159265358979323)
True
sage: hash(pi)
2943215493
sage: hash(3.14159265358979323)
1826823505
sage: dd
{3.1415926535897932: 'approx', pi: 'exact'}
sage: {0:"exact", 0.0000000000000000000:"approx"}
{0: 'approx'}
}}}
as a consequence
{{{
sage: pii = 3.14159265358979323
sage: bool(pii == pi)
True
sage: dd = {pi: "exact"}
sage: pi in dd
True
sage: pii in dd
False
sage: pii in dd.keys()
True
    sage: bool(pi == 3.14159265358979323)
    True
    sage: hash(pi)
    2943215493
    
sage: hash(3.14159265358979323)
    1826823505
    sage: dd
    
{3.1415926535897932: 'approx', pi: 'exact'}
    sage: {0:"exact", 0.0000000000000000000:"approx"}
    {0: 'approx'}

as a consequence::

    
sage: pii = 3.14159265358979323
    sage: bool(pii == pi)
    True
    sage: dd = {pi: "exact"}
    sage: pi in dd
    True
    sage: pii in dd
    False
    sage: pii in dd.keys()
    True

Equality and Coercion could be harmful

The goal of this page is to gather all problems due to equality accepting coercion in borderline cases:

sage: bool(pi == 3.14159265358979323)
True
sage: hash(pi)
2943215493
sage: hash(3.14159265358979323)
1826823505
sage: dd
{3.1415926535897932: 'approx', pi: 'exact'}
sage: {0:"exact", 0.0000000000000000000:"approx"}
{0: 'approx'}

as a consequence:

sage: pii = 3.14159265358979323
sage: bool(pii == pi)
True
sage: dd = {pi: "exact"}
sage: pi in dd
True
sage: pii in dd
False
sage: pii in dd.keys()
True

EqualityCoercion (last edited 2017-03-13 22:32:31 by hivertwiki)