Converting Binary To Hexadecimal
I am converting binary to hexadecimal but the code below returns a wrong answer: var number = 1011; var hexa = parseInt(number, 2).toString(16); return hexa; This returns b but it
Solution 1:
'b' is correct. Hexadecimal doesn't specify letter case, and many write hex strings with lower-case letters.
Solution 2:
Just add toUpperCase()
:
var hexa = parseInt(number, 2).toString(16).toUpperCase();
Post a Comment for "Converting Binary To Hexadecimal"