Is there a “normal” EqualQ function in Mathematica?

后端 未结 7 666
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-24 03:49

On the documentation page for Equal we read that

Approximate numbers with machine precision or higher are considered equal if they d

7条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-24 04:28

    In[12]:= MyEqual[x_, y_] := Order[x, y] == 0
    
    In[13]:= MyEqual[1.0000000000000021, 1.0000000000000022]
    
    Out[13]= False
    
    In[14]:= MyEqual[1.0000000000000021, 1.0000000000000021]
    
    Out[14]= True
    

    This tests if two object are identical, since 1.0000000000000021 and 1.000000000000002100 differs in precision they won't be considered as identical.

提交回复
热议问题