notes.txt: Add link to Z3 model_compress bug.
[libguestfs-talks.git] / 2020-frama-c / 5000-power-of-2.html
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>
4
5 <h1>nbdkit is_power_of_2</h1>
6
7 <pre class="code">
8   /* Returns true if v is a power of 2.
9    *
10    * Uses the algorithm described at
11    * http://graphics.stanford.edu/~seander/bithacks.html#DetermineIfPowerOf2
12    */
13   static inline bool
14   is_power_of_2 (unsigned long v)
15   {
16     return v && ((v & (v - 1)) == 0);
17   }
18 </pre>