# How to convert a float number to the whole number in JavaScript?

There are various methods to convert float number to the whole number in JavaScript.

1. Math.floor (floating argument): Round off the number passed as parameter to its nearest integer in Downward direction.
Syntax:

`Math.floor(value)`

 ` `

Output :

```Converted value of 4.59 is 4
```
2. Math.ceil (floating argument): Return the smallest integer greater than or equal to a given number.
Syntax:

`Math.ceil(value)`

 ` `

Output :

```Converted value of 4.59 is 5
```
3. Math.round (floating argument): Round a number to its nearest integer.
Syntax:

`Math.round(var);`

 ` `

Output :

```Converted value of 4.59 is 5
```
4. Math.trunc (floating argument): Return the integer part of a floating-point number by removing the fractional digits.
Syntax:

`Math.trunc(value)`

 ` `

Output :

```Converted value of 4.59 is 4
```
5. parseInt (floating argument): Accept the string and convert it into an integer.
Syntax:

```parseInt(Value, radix)
```

 ` `

Output :

```Converted value of 3.54 is 3
```
6. double bitwise not (~~) operator: Round a number to towards zero. If the operand is a number and it’s not NaN or Infinity.
Syntax:

`~~value`

 ` `

Output :

```Converted value of 4.59 is 4
```
7. bitwise OR (|) operator: Round a number to towards zero.
Syntax:

`var = value | 0;`

 ` `

Output :

```Converted value of 5.67 is 5
```
8. Using shift (>>) operator: Round a number to towards zero.
Syntax:

`var = value >> 0;`

 ` `

Output :

```Converted value of 5.63 is 5
```
9. Using unsigned shift (>>>) operator Round a number to towards zero.
Syntax:

`var = value >>> 0;`

 ` `

Output :

```Converted value of 5.68 is 5
```
10. By subtracting the fractional part
Syntax:

`var = val - val%1;`

 ` `

Output :

```Converted value of 5.48 is 5
```
11. Using XOR (^) operator
Syntax:

`var = value ^ 0;`

 ` `

Output :

```Converted value of 5.49 is 5
```

My Personal Notes arrow_drop_up I am a quick learner and eager to learn new technologies

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

Article Tags :

Be the First to upvote.

Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.