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-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

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

This article introduces the relevant knowledge of "how to convert binary to hexadecimal in JavaScript". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

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)

This is the end of "how to convert binary to hexadecimal in JavaScript". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

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