Common methods of the math class

Source: Internet
Author: User

math.abs () returns the absolute value of the specified number.

Math.max () and math.min () return two parameters (belonging to the same number type), respectively, to the larger number and the smaller number.

Math.pow () returns the base of the first argument, and the second argument is the result of a power operation of the exponent.

Math.ceil () ceil means the ceiling, which means rounding up. As the result of Math.ceil (11.3), the result of 12,math.ceil (-11.3) is-11.

Math.floor () floor means flooring, which means rounding down. As the result of Math.floor (11.6), the result of 11,math.floor (-11.6) is-12.

Math.Round () The method represents rounding, the algorithm is Math.floor (x+0.5), and the original number plus 0.5 is rounded down. Such as:

The result of Math.Round (8.9) is that the result of 9,math.round (8.1) is 8.

The result of Math.Round (-8.9) is that the result of -8,math.round (-8.1) is-8.

math.random () This method represents taking a random number and returning a double with a positive value, which is [0, 1].

Common methods of the math class

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.