How can I assign a hexadecimal number to another number?

How can I assign the code below to a number?

Integer.toHexString (myHexValue);

+1


a source to share


3 answers


The second optional argument to parseInt is radix.



parseInt("0xff", 16);
// yields 255

      

+5


a source


Convert it back to integer ...



var s = "FFFFFF";
var n = parseInt("0x"+ s);

      

+1


a source


You can specify the hexadecimal value as "Number". For instance:

foo = Number(0xDEADBEEF)

      

Hope it helps.

0


a source







All Articles