How to convert binary to hexadecimal in JavaScript
Today, I would like to share with you how to convert binary to hexadecimal in JavaScript. The content is detailed and the logic is clear. I believe most people still know too much about this knowledge, so share this article for your reference. I hope you can get something after reading this article.
The method of converting binary to hexadecimal in JavaScript
Vara=100
Varb=parseInt (a par 2)
Tostrin (16)
Introduction to related functions:
ParseInt () parses the string and returns an integer.
ParseInt () determines the cardinality based on the string when the value of the parameter radix is 0, or when the parameter is not set.
When the parameter cardinality is ignored, the cardinality of the JavaScript default number is as follows:
If the string starts with "0x", parseInt () parses the rest of the string into hexadecimal integers.
ECMAScript v3 allows the implementation of parseInt () to parse the following characters into octal or hexadecimal numbers if the string begins with 0.
If the string begins with a number between 1 and 9, parseInt () parses it to a decimal integer.
Grammar
Parse (string, cardinality)
Function converts an Number object to a string and returns the result.
Grammar
Number.toString (cardinality)
Binary conversion:
1. Conversion between decimal and binary, octal and hexadecimal
Vara=111, decimal to binary
A.toString (2) 2, decimal to octal
A.toString (8) 3, decimal to hexadecimal
A.toString (16) binary, binary, octal, hexadecimal and decimal conversion
1, binary to decimal
Varb=100
ParseInt (bmeme2); 2, octal to decimal
Varc=100
ParseInt (cPol 8); 3. Conversion from hexadecimal to decimal
Vard=100
ParseInt (dline 16)
These are all the contents of the article "how to convert binary to hexadecimal in JavaScript". Thank you for reading! I believe you will gain a lot after reading this article. The editor will update different knowledge for you every day. If you want to learn more knowledge, please pay attention to the industry information channel.