Friday 17 May 2013

Modulo adjustment

If you open MDN pages, describing Math.ceil, Math.floor, and Math.round, you will find the good example of the adjustment and rounding based on the decimal logarithm. For exdample, Math.ceil10(55, 2) returns 100 where 2 expresses an exponent for 10^2.

Besides of logarithmic adjustment we can use modulo based adjustment. It is almost the same as above but uses an arbitrary number for adjustment.