Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to convert binary to hexadecimal in JavaScript

2025-04-10 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)05/31 Report--

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.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report