Skip to content

SameQ for PrecisionReal #146

@mmatera

Description

@mmatera

When SameQ is applied to two PrecisionReal numbers that differ in a quantity under the precision, WMA returns True, while Mathics returns False. The issue does not affect Equal. For example, in WMA,

In[1]:= a=N[2/9,3]; b=0.22222`5; {a,b,a==b, a===b}

returns

Out[1]= {0.222,0.22222,True, True}

while in Mathics,

Out[1]:=  {0.222,0.22222,True, False}

This issue comes up when we try to implement low-level tests (see for example #145), and seems to be related to how the comparison operator is implemented in mpf.

A similar issue comes up if we evaluate a-b. In WMA,

In[2]:= a=N[2/9,3]; b=0.22222`5; {a-b, Precision[a-b]}

results in

Out[2]={0.`, 0.}

while in Mathics,

Out[2]={0.0000153, 3.}

A possible fix would be to check the precision in PrecisionReal.sameQ and in the constructors of Real and PrecisionReal..

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions