Here you can find the source of roundTo (num, to)
// Ceils to a given number Math.ceilTo = function roundTo (num, to) { if (num < to) { return to; }/*w w w .j a v a 2 s. com*/ var amount = to * Math.ceil(num / to); if (amount === 0) { amount = to; } return amount; };
Math.roundTo = function (num, dec) { return Math.round(num * Math.pow(10, dec)) / Math.pow(10, dec); };
Util.round = function(value) { return new Number((new Number(value)).toFixed(2)); };
Math.roundTo = function roundTo (num, to) { if (num < to / 2) { return 0; var amount = to * Math.round(num / to); if (amount === 0) { amount = to; return amount; ...
function MyMath () {} MyMath.decRound = function(num, decimals){ return Math.round(num*Math.pow(10,decimals))/Math.pow(10,decimals);
Number.prototype.$round = function(fractionalDigits) { return parseFloat(this.toFixed(fractionalDigits)); };
Number.prototype.ToRound = function (digits) { if (digits < 0 || digits > 10) return this; var pow10 = Math.pow(10, digits); return Math.round(this * pow10) / pow10; };