JavaScript parseint character conversion to digital function Use Summary _ basics

Source: Internet
Author: User
Today when the test found the problem, when the database in the month of 09 when the problem, with the parseint conversion after the 0. So puzzled. Measured for a long time, did not find the problem in my code, to Google search a bit, just know it is such a thing.

For parseint ("01") to Parseint ("a");p Arseint ("10") to be able to get the correct results, but if it is parseint ("08") or parseint ("09") returns 0; First look at the parseint Syntax: parseint (string, radix); If the following argument is not written, the first one is judged as String, radix is binary, octal, hexadecimal, or decimal. When the default does not specify radix, when the 0x switch is 16, if the 0 switch and the second digit is not X, then it is octal (because octal cannot have 8, 9 so the error returns 0). If you start with 1 in decimal, you are right after 10, so when we use it, we explicitly specify the rounding to prevent errors. If we usually use decimal digits, we will parseint ("08", 10);
So, it is wrong, in the future when the use of the best in the parseint this function plus the number of numbers, to ensure that there is no error, otherwise, the error for several hours.!!!!!!!!!!
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.