Skip to content
Advertisement

Convert string binary to hexadecimal

JavaScript

Hi everyone, I am trying to convert String of Binary to Hexadecimal. My string binary is “1110101011111010”. The output should be EAFA, but my output is EA7A. What’s wrong with my code? Can anybody help me, please?

Advertisement

Answer

In case you expect a long string, you can use BigInteger to convert any binary string to hexadecimal.

JavaScript

Output:

JavaScript

JavaScript

Output:

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement