This article describes the common digital binary conversion method in JavaScript. Share it for your reference, as follows:
The basic idea is to convert other fundamentals into decimals first, and then convert them. This process uses the parseInt function, for example, converting a hexadecimal number (num) into decimal, num = parseInt(num,16). If you want to convert it into binary, it is as follows: num.toString(2).
This is also very special about hexadecimal. The escape function can convert a string into a hexadecimal number.
Here is a comprehensive example:
var a = escape(code); //code is a hexadecimal string, a is a hexadecimal number var b = parseInt(a,16); // Convert hexadecimal number into decimal var c = b.toString(2); // Convert decimal to binary var d = (c+'').slice(-2,-1); // Convert c+'' to convert numbers into a string is a trick. Take the penultimate number in this binary number
Friends who are interested in logarithmic conversion and calculation can also refer to the tools of this site:
Scientific Calculator Online Use_Advanced Calculator Online Calculator
Online Calculator_Standard Calculator
Online scientific calculator flash version
For more information about JavaScript related content, please check out the topics of this site: "Summary of JavaScript switching effects and techniques", "Summary of JavaScript search algorithm skills", "Summary of JavaScript animation effects and techniques", "Summary of JavaScript errors and debugging techniques", "Summary of JavaScript data structures and algorithm skills", "Summary of JavaScript traversal algorithms and techniques", and "Summary of JavaScript mathematical operations usage"
I hope this article will be helpful to everyone's JavaScript programming.