Tag: hack

JavaScript Bug – Modulo of small numbers
It seems that there is a problem with the modulo function, ‘%’, in JavaScript. For example: 10 % 0.1 should equate to zero but comes out as 0.09999999999999945 probably due to some internal floatingpoint rounding errors. Easy solution (a hack really): Multiply both numbers by 1000 before using the modulo function.