1 var comb = exports; 2 3 /** 4 * Determines if obj is a number 5 * 6 * @param {Anything} obj the thing to test if it is a Number 7 * 8 * @returns {Boolean} true if it is a number false otherwise 9 */ 10 comb.isNumber = function(obj) { 11 var undef; 12 return obj !== undef && obj != null && (typeof obj == "number" || obj instanceof Number); 13 }; 14 15 /** 16 * @private 17 */ 18 var round = Math.round, pow = Math.pow; 19 20 /** 21 * @namespace Utilities for numbers 22 */ 23 comb.number = { 24 /** 25 * Rounds a number to the specified places. 26 * 27 * 28 * @param {Number} num the number to round. 29 * @param {Number} places the number of places to round to. 30 */ 31 round : function(number, places, increment) { 32 increment = increment || 1e-20; 33 var factor = 10 / (10 * (increment || 10)); 34 return (Math.ceil(factor * +number) / factor).toFixed(places) * 1; // Number 35 } 36 };