JavaScript Common digital Conversion instance Analysis _javascript skill

Source: Internet
Author: User

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.