Flooring using double bitwise not

An interesting tidbit from Thomas Fuchs’ Extreme Javascript Performance:

~~(1 * 12.5) is faster than parseInt(12.5).

The ~~ is a double bitwise not, and the multiplication by one forces a string into a float.

Via Janne’s Delicious stream.

---

There are 3 other entries posted on this day.


  • Home
  • About
  • Preferences