Introduction to ParseInt function parameter settings

Source: Internet
Author: User

We often use the ParseInt function to convert the string to an int value. The ParseInt function has two parameters that can be set. The second parameter can be set by default.

ParseInt ("string", in hexadecimal format)

Var num1 = ParseInt ("10", 2) // 2

Var num1 = ParseInt ("10", 8) // 8

Var num1 = ParseInt ("10", 10) // 10

Var num1 = ParseInt ("10", 16) // 16

Hexadecimal parameters can be in hexadecimal notation 16, 8, 10, or 2.

We usually use the hexadecimal notation. We 'd better always use the second parameter and set it to 10. If there is no second parameter, the function determines how to choose the hexadecimal notation. (Problems may occur. For example, "070" ECMAScript 3 considers it octal ECMAScript 5 as decimal)

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.