The examples in this article describe the common method of digital conversion in JavaScript. Share to everyone for your reference, specific as follows:
The basic idea is to first convert the other into decimal, and then convert. This process uses the parseint function, such as converting a 16-digit number (num) to 10, num = parseint (num,16). If you want to convert it into binary, it is as follows: Num.tostring (2).
One of the functions of the 16 binary is also special, and the Escape function converts a string into a 16-digit number.
The following is a comprehensive example:
var a = Escape (code); The code is a hexadecimal string, and a is a hexadecimal number
var b = parseint (a,16);//Convert the hexadecimal number to decimal
var c = b.tostring (2);//convert decimal
to binary var d = (c+ '). Slice ( -2,-1); Where c+ ' converts numbers into a string, is a trick. Take the penultimate number in this binary number
Log system conversion and operations interested friends can also refer to the site tools:
Scientific Calculator Online Use _ Advanced calculator online calculation
Online Calculator _ Standard Calculator
Online Science Calculator Flash edition
More readers interested in JavaScript-related content can view the site topics: "JavaScript switching effects and tips summary", "JavaScript Search Algorithm Skills Summary", "JavaScript animation effects and tips summary", " JavaScript error and debugging skills Summary, JavaScript data structure and algorithm skills summary, JavaScript traversal algorithm and skills summary and JavaScript mathematical calculation usage Summary
I hope this article will help you with JavaScript programming.