JavaScript arithmetic operations (use of the Math object)

Source: Internet
Author: User
Tags natural logarithm pow square root

JavaScript supports complex arithmetic operations, which are implemented by functions and constants defined as properties of the Math object:

Math.pow (2,53)//= 2 of 53 square, exponentiation operation

Math.Round (. 6)//+ = 1.0: Rounding

Math.ceil (. 6)//+ = 1.0: Rounding up

Math.floor (. 6)//+ = 0.0: Rounding Down

Math.Abs ( -5)//= 5: Absolute value

Math.max (x, y, z)//return maximum value

Math.min (x, y, z)//= = Returns the minimum value

Math.random (. 6)//Generate a pseudo-random number greater than or equal to 0 less than 1.0

Math.PI//pi: Pi

MATH.E//E: base of natural logarithm

Square root of Math.sqrt (3)//3

Math.pow (3,1/3)//3 cube root

Math.sin (0)//trigonometric functions, Math.Cos and Math.atan, etc.

Natural logarithm of Math.log (10)//10

Math.log (+)/MATH.LN10//logarithm of base 100 for 10

Math.log (/MATH.LN2)//logarithm of base 512 for 2

Math.exp (3) 3 power of//e

JavaScript arithmetic operations (use of the Math object)

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.