I have seen many people using bitwise operators to remove decimal parts, or round off a number, using bitwise operators.
But, I want to know how actually this work?
let a = 13.6 | 0; //a == 13
let b = ~~13.6; // b == 13
I did search for the same. The best I could find was this.
People there are talking about efficiency, pros and cons. I am interested in how this actually works?
All bitwise operations except unsigned right shift, >>>, work on signed 32-bit integers. So using bitwise operations will convert a float to an integer.
So using bitwise operations will convert a float to an integer. But how?