JS only retains integers, rounded up, rounding, and rounding down functions

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

1. Discard the fractional part, preserving the integer part parseint (5/2) 2. Rounding up, with decimals on the integer part plus 1math.ceil (5/2) 3, rounded. Math.Round (5/2)

1. Discard the fractional part, preserving the whole number of parts
parseint (5/2)

2. Rounding up, with decimals on the integer part plus 1

Math.ceil (5/2)

3, rounded.

Math.Round (5/2)

4, rounding down

Math.floor (5/2)

Methods of the Math object
Method Description
ABS (x) The absolute value of the return number
ACOs (x) Inverse cosine value of the return number
ASIN (x) The inverse chord value of the returned number
Atan (x) Returns the inverse tangent of x with a value between-PI/2 and PI/2 radians
ATAN2 (y,x) Returns the angle from x-axis to point (x, y) (between-PI/2 and PI/2 radians)
Ceil (x) Rounds a number.
COS (x) Cosine of the returned number
EXP (x) Returns the exponent of E.
Floor (x) Rounds down a number.
Log (x) Natural logarithm of the number of returns (Bottom is E)
Max (x, y) Returns the highest value in X and Y
Min (x, y) Returns the lowest value in X and Y
Pow (x, y) Returns the Y power of X
Random () Returns a random number between 0 ~ 1
Round (x) Rounding a number to the nearest integer
Sin (x) The sine of the returned number
sqrt (x) The square root of the returned number
Tan (x) Returns the tangent of a corner
Tosource () The source code that represents the object
ValueOf () Returns the original value of a Math object

JS only retains integers, rounded up, rounding, and rounding down functions

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.