1Number.prototype.radix = function(r, n, c) { 2 if (!r) return this.valueOf(); 3 if (!c) c = '0'; 4 return this.toString(r).padLeft(Math.abs(n), c); 5} 6 7Number.prototype.bin = function(n, c) { 8 return this.radix(0x02, (isUndefined(n))?16:n, c); 9} 10 11Number.prototype.oct = function(n, c) { 12 return this.radix(0x08, (isUndefined(n))?6:n, c); 13} 14 15Number.prototype.dec = function(n, c) { 16 return this.radix(0x0A, (isUndefined(n))?2:n, c); 17} 18 19Number.prototype.hex = function(n, c) { 20 return this.radix(0x10, (isUndefined(n))?4:n, c); 21} 22