double bitwise not (~~) operator
Round a number to zero. If an operand is a number and it’s not NaN or Infinity.
Syntax:
~~value
Example: Here is the example of a not(~~) operator.
javascript
// float value is 4.59; let x = 4.59; let z = ~~x; console.log( "Converted value of " + x + " is " + z); |
Output:
Converted value of 4.59 is 4
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:
Contact Us