MikeMcl/bignumber.js — pull request #8 by lachlanhunt (2013-05-19 21:34:44+00:00)
Title: Modulo rounding

I implemented support for alternative rounding modes in the modulo operation. The advantage is that it now supports more than just truncated rounding.

JavaScript's remainder operator (%) used truncated rounding, but this isn't particularly useful for all cases of mod. Common alternative rounding modes are floored and Euclidian (See wikipedia).

I added a MODULO_MODE variable which is similar to the ROUNDING_MODE variable, but is used for the mod operation. I also added a ROUND_EUCLID value which is for Euclidian rounding in the modulo operation. (It doesn't really make sense for ROUNDING_MODE though).

http://en.wikipedia.org/wiki/Modulo_operation#Remainder_calculation_for_the_modulo_operation