Wednesday, April 25, 2007

#26

How do we test most simply if an unsigned integer is a power of two?

Answer:

    f = !(v & (v - 1)) && v;

No comments: