by larsu · 16y ago · 0 comments
Now it finally gets more interesting!!! Bit hacks #1 - #5 were kind of boring to be honest.
Does anybody know a practical use case for that? I have personally never encountered a situation were I needed to manipulate the right most 1-bit.
Otherwise it's a nice introduction to bit hacking.
That's the context I learned this trick in. It's used in the Embarcadero (ex-Borland) compilers (Delphi, C++, etc.).
while flags!=0:
right_most = flags & (-flags)
process(right_most)
flags &= ~right_most