1 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
2 <link rel="stylesheet" href="style.css" type="text/css"/>
3 <script src="code.js" type="text/javascript"></script>
5 <h1>nbdkit is_power_of_2</h1>
8 /* Returns true if v is a power of 2.
10 * Uses the algorithm described at
11 * http://graphics.stanford.edu/~seander/bithacks.html#DetermineIfPowerOf2
14 is_power_of_2 (unsigned long v)
16 return v && ((v & (v - 1)) == 0);