bit twiddling hacks for JavaScript