title: How to generate a boolean with p probability using C rand() function?
body: <p>How can I generate a random boolean with a probability of <code>p</code> (where 0 &lt;= p &lt;= 1.0) using the C standard library <code>rand()</code> function?</p>
  
  <p>i.e.</p>
  
  <pre><code>bool nextBool(double probability)
  {
      return ...
  }
  </code></pre>