Math.ceil (floating argument)
Return the smallest integer greater than or equal to a given number.
Syntax:
Math.ceil(value);
Example: Here is the basic use of the Math.ceil() method.
javascript
// float value is 4.59; let x = 4.59; let z = Math.ceil(x); console.log( "Converted value of " + x + " is " + z); |
Output:
Converted value of 4.59 is 5
How to convert a float number to the whole number in JavaScript ?
In this article, we will convert a float number to a whole number in JavaScript.
Below are various methods to convert float numbers to whole numbers in JavaScript:
Table of Content
- Math.floor (floating argument):
- Math.ceil (floating argument)
- Math.round (floating argument)
- Math.trunc (floating argument)
- parseInt (floating argument)
- double bitwise not (~~) operator
- JavaScript bitwise OR (|) Operator
- Using shift (>>) operator
- Using unsigned shift (>>>) operator
- By subtracting the fractional part
- Using XOR (^) operator Syntax: