Javascript pipe in math to get Math.floor without using Math.floor
This question already has an answer here:
A single pipe | is BitWise OR.
Bitwise operator only allow integer values, so after decimal point value is discarded.
Bitwise OR operator | takes 2 bit patterns, and perform OR operations on each pair of corresponding bits.
The following example will explain it.
1010
1100
----------bitwise or
1110
(9+2)/2 is 5.5 in JavaScript Or operation. For JavaScript, the bitwise operations don't work directly on the 64-bit representations. Instead, the value is converted into a 32-bit integer, which means 5.5 to 5 , then the result of 5|0 is 5 . 