Hacker News new | past | comments | ask | show | jobs | submit login

Ah, thanks for the correction.

I don't currently have a license, so out of curiosity is 0.3 == 3/10 in wolfram?




Yes 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




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: