Node.js examples for Number:Hex
Convert number to hex string
Number.prototype.toHexString = function() { if (this === null) { return null; } if (isNaN(this)) { return this; } var num;// w ww . j av a 2 s .c o m var hex; if (this < 0) { num = 0xFFFFFFFF + this + 1; } else { num = this; } hex = num.toString(16).toUpperCase(); return "0x" + ("00000000".substr(0, 8 - hex.length) + hex); }