+ 4
[SOLVED]Difference between Math.floor(),Math.ceil() and Math.round()
What is the difference between Math.floor(),Math.ceil() and Math.round()
3 ответов
+ 7
round() is rounding
1.6 -> 2
9.4 - > 9
floor() is rounddown
1.6 -> 1
-2.1 -> -3
ceil() is roundup
3.1 -> 4
+ 3
Math.round will round the number to its nearest range depending on the unit, If the tenth place is less than 5 then it would be rounded to the nearest low number but if it's greater than 5 or 5 then it will be the opposite For eg: 3.3=> 3, 3.6=>4 etc.
Math.floor will round it to the below number. For eg: 3.4=> 3, 3.6=>3 etc.
Math.ceil will round it to the above number. For eg: 3.4=> 4, 3.6=>4 etc.