List of utility methods to do Number Convert
toPrecisionFixed(precision)Number.prototype.toPrecisionFixed = function(precision) { var n = this.toPrecision(precision); n = n.replace(/(.+)e\+(.+)/, function(n, sig, exp) { sig = sig.replace(/\./, ''); l = sig.length - 1; while (exp-- > l) sig = sig + '0'; return sig; }); n = n.replace(/(.+)e-(.+)/, function(n, sig, exp) { ... | |
toPrecision(length)Number.prototype.toPrecision = function toPrecision(length) { return parseFloat(this.toFixed(length)); }; | |
toS()function numberToPx(number) { return number + "px"; function getMilliseconds(timestampStr) { var timestampStrSplit = timestampStr.split("."); var milli = Date.parse("January 1, 1970 " + timestampStrSplit[0] + " UTC"); if (timestampStrSplit.length == 1) return milli; else (timestampStrSplit.length == 2) ... | |
to_feet()Number.prototype.to_feet = function() { return this / 0.3048; }; |