3 ms·
Even in Wolfram, 0.1 is not the same as 1/10. In[1]:= Precision[0.1] Out[1]= MachinePrecision In[2]:= Precision[1/10] Out[2]= \[Infinity]
by kccqzy 8y ago
Even in Wolfram, 0.1 is not the same as 1/10.
In[1]:= Precision[0.1]
Out[1]= MachinePrecision
In[2]:= Precision[1/10]
Out[2]= \[Infinity]
- twtw 8y agoAh, thanks for the correction. I don't currently have a license, so out of curiosity is 0.3 == 3/10 in wolfram?
- kccqzy 8y agoYes that's true. According to the documentation of Equal†, > Approximate numbers with machine precision or higher are considered equal if they differ in at most their last seven binary digits (roughly their last two decimal digits). Which is why in Mathematica, 0.1+0.2==0.3 is also True. If you need a kind of equality comparison that returns False for 0.3 and 3/10, use SameQ. Funnily, SameQ[0.1+0.2,0.3] is also True, because SameQ allows two machine precision numbers to differ in their last binary digit. †: https://reference.wolfram.com/language/ref/Equal.html https://reference.wolfram.com/language/ref/Equal.html