Monday, March 5, 2012

How to round up a number in Javascript

Here a small code to round up a number in javascript:
function roundUp(number, decimals){
var decimalPow=Math.pow(10,decimals);
var result = Math.ceil(number*decimalPow)/decimalPow;
return result;
}
view raw gistfile1.js hosted with ❤ by GitHub

No comments: