3
$\begingroup$

I am using Mathematica 11.1.1 and I was surprised when I saw:

Mod[0.2, 0.2] == 0.
Mod[0.4, 0.2] == 0.
Mod[0.6, 0.2] == 0.2
Mod[1.0, 0.2] == 0.2

I cannot understand why the last two results are wrong!!

$\endgroup$
  • $\begingroup$ Mod 0.2, they are correct, since Mod[0.,0.2] equals Mod[0.2,0.2]... However, this is weird, indeed. $\endgroup$ – Henrik Schumacher Jul 31 '17 at 8:32
  • 2
    $\begingroup$ This is not surprising at all; see this, and evaluate Mod[6/10,2/10]. $\endgroup$ – corey979 Jul 31 '17 at 8:36
  • $\begingroup$ @corey979 Doh. Right... $\endgroup$ – Henrik Schumacher Jul 31 '17 at 8:50