public static double mod ( double a , double div ) { final double remainder = a % div ; return remainder < 0 ? remainder + div : remainder ; }
Returns the modulo of a by div with corrections for negative numbers .