MySQL MOD() is broken: Is this the best alternative?
At least in MySQL v5.1.73 (CentOS 6.6), MOD() function returns a bogus result... unless someone can explain how this is actually correct. mysql> select MOD(-385.4784399 ,1440); +-------------------------+ | MOD(-385.4784399 ,1440) | +-------------------------+ | -385.4784399 | +-------------------------+ 1 row in set (0.01 sec) Is this the best alternative? mysql> select -385.478439885319 - 1440 * FLOOR(-385.478439885319/1440); +----------------------------------------------------------+ | -385.478439885319 - 1440 * FLOOR(-385.478439885319/1440) | +---------------------------------------------