Here you can find the source of toMaxDecimal(d)
var k2c = k => k - 273.15 var k2r = k => k * 1.8 var k2f = k => k2r(k) - 459.67 Number.prototype.toMaxDecimal = function (d) { return +this.toFixed(d) + '' } function kCnv(k) { document.write( k,'K? = ', k2c(k).toMaxDecimal(2),'C? = ', k2r(k).toMaxDecimal(2),'R? = ', k2f(k).toMaxDecimal(2),'F?<br>' ) } kCnv(21)/* w ww. j ava 2 s . c om*/ kCnv(295)
Number.prototype.toDecimal = function(){ if(this > 0){ return this / 100; }else{ return this * 1; };
Number.prototype.toDecimal = function(value) { var precision = 2; var power = Math.pow(10, precision || 0); return String(Math.round(value * power) / power); };
Number.prototype.toDecimalPrecision = function(number_of_decimal_places) { var components = ("" + this).split('.') if (components[0] == undefined) components[0] = "0"; if (components[1] == undefined) components[1] = "0"; return components[0] + '.' + components[1].substr(0,number_of_decimal_places)
Number.prototype.toMaxFiexed = function (digits) { var ret = this.toFixed(digits); ret = ret.replace(/0+$/, '').replace(/\.$/, ''); return ret; function HTMLEncode (input) { var converter = document.createElement("DIV"); converter.innerText = input; var output = converter.innerHTML; ...
Number.prototype.toMillions = function() { return (this / 1000000).toFixed(1) + 'M'; };