Math. ceil (), Math. floor (), Math. round () functions in JavaScipt

Source: Internet
Author: User
Tags prototype definition

First, let's take a look at The definition of three functions in JavaScript: The Definitive Guide, 4th Edition.

Math. ceil (): roundNumber up

Arguments: Any numeric value or expression

Returns: The closest integer greater than or equalX.

Bytes -----------------------------------------------------------------------------------------------

Math. floor (): roundNumber down

Arguments: Any numeric value or expression

Returns: The closest integer less than or equalX.

Bytes -----------------------------------------------------------------------------------------------

Math. round (): round toNearest integer

Arguments: Any number.

Returns: The integer closestX.

 

In the past, the use of the three functions has been confusing. Now, by understanding the prototype definition of the three functions, it is easy to remember the three functions.

Now let's make a summary:

1. Math. ceil () is used as the rounded up integer.

2. Math. floor () is used for downgrading.

3. Math. round () the rounding round we often use in mathematics.

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.