Using right shifts, you can compute the next power of two of an 32-bit integer in a very effective way: For example, the size of a texture should be usually a power of two, so this code comes in very handy.
  1. Melvar (2011-01-19 08:59)

    I find it rather strange that you don’t seem to consider one a power of two (it’s 2⁰ and the smallest integer power of two).

  2. joe (2011-01-19 09:23)

    Oopps… fixed it. Thank you.

Add your comment now