The usage summary of the random,round,ceil,floor of the math in JS _javascript skill

Source: Internet
Author: User
Tags numeric value

<span style= "font-size:18px" >1.math.random (); The result is a random number between 0-1 (including 0, excluding 1) </SPAN>
Math.random (); The result is a random number between 0-1 (including 0, not including 1) [HTML] view Plaincopyprint?
<span style= "font-size:18px" >

2.math.floor (num); Parameter num is a numeric value, and the function result is the integer portion of NUM (returns the largest integer less than or equal to N). </SPAN>


Math.floor (num); Parameter num is a numeric value, and the function result is the integer portion of NUM (returns the largest integer less than or equal to N). [HTML] View Plaincopyprint?
<span style= "font-size:18px" >

3.math.round (num); The parameter num is a numeric value, and the function result is the integer rounded by Num. </SPAN>


Math.Round (num); The parameter num is a numeric value, and the function result is the integer rounded by Num. [HTML] View Plaincopyprint?
<span style= "font-size:18px" >

4.math.ceil (n); Returns the smallest integer greater than or equal to N. </SPAN>


Math.ceil (n); Returns the smallest integer greater than or equal to N. [HTML] View Plaincopyprint?
<span style= "font-size:18px" >

5.math.ceil (Math.random () *10); , the number of random integers from 1 to 10 is mostly obtained, and the probability of taking 0 is minimal. </SPAN>


Math.ceil (Math.random () *10), the main gain is 1 to 10 of the random integer, the probability of taking 0 is very small. [HTML] View Plaincopyprint?
<span style= "font-size:18px" >

6.math.round (Math.random ()); A random integer of 0 to 1 can be obtained evenly. </SPAN>


Math.Round (Math.random ()); a random integer from 0 to 1 can be obtained evenly. [HTML] View Plaincopyprint?
<span style= "font-size:18px" >

7.math.round (Math.random () *10); , a random integer of 0 to 10 can be basically balanced, with half the probability of obtaining a minimum value of 0 and a maximum of 10. </SPAN>


Math.Round (Math.random () *10), the random integer from 0 to 10 is basically balanced, with half the probability of obtaining a minimum value of 0 and a maximum of 10. [HTML] View Plaincopyprint?
<span style= "font-size:18px" >

8.math.floor (Math.random () *10); , a random integer of 0 to 9 can be obtained evenly. </SPAN>

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.