That's not broken, just don't ever use == when doing floating point math, it won't work most of the time. (google why)
Don't see a logical explanation for the modulo right now but it works fine for positive numbers (what do you need the negative ones for?)