Number.prototype.radix = function(r, n, c) { if (!r) return this.valueOf(); if (!c) c = '0'; return this.toString(r).padLeft(Math.abs(n), c); } Number.prototype.bin = function(n, c) { return this.radix(0x02, (isUndefined(n))?16:n, c); } Number.prototype.oct = function(n, c) { return this.radix(0x08, (isUndefined(n))?6:n, c); } Number.prototype.dec = function(n, c) { return this.radix(0x0A, (isUndefined(n))?2:n, c); } Number.prototype.hex = function(n, c) { return this.radix(0x10, (isUndefined(n))?4:n, c); }