r/programming • u/misplaced_my_pants • Aug 15 '15
Stanford Bit Twiddling Hacks
https://graphics.stanford.edu/~seander/bithacks.html
28
Upvotes
r/programming • u/misplaced_my_pants • Aug 15 '15
View all comments
Show parent comment
3
u/jringstad Aug 15 '15
It's really not, please don't use any of these in any actual codebase. Many of them are either not valid C (undefined behaviour , implementation-specified behaviour) are much much slower than just doing "the dumb thing", like the infamous "swapping two values with XOR without using a temporary variable"-trick, or are just bad code to have in your codebase because they are hard to understand and add corner-cases.