JavaScript Learning Record

Source: Internet
Author: User
What you javascript should be aware of during the type conversion process
  1. Floating point integral type

    Problem:
    When using the parseInt transform data, it should be determined that the converted data does not appear 0.0000006 such a valid number in the decimal point of the 7th digit and above the data,
    The method of converting the data is parseInt called arg.toString() , which causes the 0.0000008 conversion 8e-7 to occur, and the parseInt(0.0000008) //打印出:8 unwanted condition occurs.
    The right solution:
    Using bitwise operators

function convertToIn(num){ return num >>0; } convertToInt(-Math.PI) //>>-3 --- convertToInt(12.3424) //>>12 convertToInt(-0.000000000004) //>> 0

JavaScript Learning Record

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.