Name: Anonymous 2023-06-27 1:10
Besides the obvious set/get/clear bit mask (e.g. byte |= (1 << bit_we_want_to_set)).
Mine would be determining if an integer is a power of 2. Instead of using some
unnecessary complex loop, we simply do:
Simple, but clever. If you are nub (most likely are), read up more on bit manipulation/twiddling/hack, etc.
Mine would be determining if an integer is a power of 2. Instead of using some
unnecessary complex loop, we simply do:
x && ((x & (x - 1)) == 0);
Simple, but clever. If you are nub (most likely are), read up more on bit manipulation/twiddling/hack, etc.