The modulo operator simply takes the remainder as soon as you divide the number by this.
Divide 0 by -1 and you get 0, so the result is 0.
Floating dots and doubles really know the difference between -0 and +0, although, therefore, when you take the remainder from -0, you get -0, since this is still a valid number from 0 to 1 (or -1).
This is a quirk for working with floating point numbers and special properties 0, as well as for other numbers:
System.out.println((0.0 % -1)+","+(-0.0 % 1)+","+ (-0.0 % -1));
System.out.println((0 % -1)+","+(-0 % 1)+","+ (-0 % -1));
System.out.println((3 % -1)+","+(-3 % 1)+","+ (-3 % -1));
Output:
0.0,-0.0,-0.0
0,0,0
0,0,0
Since links were requested:
Floating points are defined in IEEE_754-1985:
http://en.wikipedia.org/wiki/IEEE_754-1985
, :
http://en.wikipedia.org/wiki/Negative_zero
, modulo :
IEEE 754 () , == C Java.
modulo >= 0 < , -0 = = ( -0 == 0), .