Entry
How to convert a hexadecimal number to a decimal one?
How to convert a binary number to a decimal one?
How to convert a number from a certain number system to a decimal one?
Feb 21st, 2000 09:58
Martin Honnen,
If you get string input of numbers in a representation other than
decimal representation you can use
parseInt('string', numberBase)
to convert that input to a decimal number for example
var sixteenHex = '10';
var sixteen = parseInt(sixteenHex, 16);
to convert from hex to decimal,
var sixteenBinary = '10000';
var sixteen = parseInt(sixteenBinary, 2);
to convert form binary to decimal,
var sixteenOctal = '20';
var sixteen = parseInt(sixteenOctal, 8);
to convert from octal to decimal.