Namespace comb.number
Utilities for numbers
Defined in: number.js.
Namespace Detail
comb.number
/**
* Rounds a number to the specified places.
*
*
* @param {Number} num the number to round.
* @param {Number} places the number of places to round to.
*/
round : function(number, places, increment) {
increment = increment || 1e-20;
var factor = 10 / (10 * (increment || 10));
return (Math.ceil(factor * +number) / factor).toFixed(places) * 1;
}
Method Detail
<static>
comb.number.round(num, places, increment)
Rounds a number to the specified places.
- Parameters:
- {Number} num
- the number to round.
- {Number} places
- the number of places to round to.
- increment
increment = increment || 1e-20;
var factor = 10 / (10 * (increment || 10));
return (Math.ceil(factor * +number) / factor).toFixed(places) * 1;
Documentation generated by JsDoc Toolkit 2.4.0 on Tue Jan 31 2012 16:14:12 GMT-0600 (CST)