links: Algorithms MOC


Did you know you can use Bitwise OR operator to floor a floating numbers

For example

let a = 13.6 | 0 // a = 13

How does it work?

  • All bitwise operators expect unsigned right shift >>> work on signed 32 bit integers, So bitwise operations will convert a float to integer.

tags: bitwise-or, javascript

source: