I stumbled over the following weird behavior when comparing floating-point numbers close to 1.0:
qq = 1.0 + 60.0 $MachineEpsilon;
and then
qq > 1.0
yields False. However,
qq - 1
yields
1.33227*10^-14
which is far above $MachineEpsilon = 2.22045*10^-16 (the smallest number eps satisfying (1.0 + eps > 1.0)==True when using 8-byte floating point numbers). Changing the first command to
qq = 1.0 + 65.0 $MachineEpsilon;
Leads to the expected behavior of (qq > 1.0) == True.
I'm running Mathematica 10.4.0.0 under Windows on an Intel i5.
Ron
SetPrecision[qq, MachinePrecision] > 1
$\endgroup$False
. $\endgroup$16
or higher,MachinePrecision
only works with aqq
rationalized asqq = 1 + 60 $MachineEpsilon
, something I did without thought, first idea with precision issues is always using rational numbers. $\endgroup$Equal
is fuzzy and mutually exclusive trichotomy is enforced. $\endgroup$