 <p>On some systems (Windows with VC springs to mind, currently), <code>RAND_MAX</code> is ridiculously small, i. e. only 15 bit. When dividing by <code>RAND_MAX</code> you are only generating a mantissa of 15 bit instead of the 23 possible bits. This may or may not be a problem for you, but you're missing out some values in that case.</p> <p>Oh, just noticed that there was already a comment for that problem. Anyway, here's some code that might solve this for you:</p> <pre><code>float r = (float)((rand() &lt;&lt; 15 + rand()) &amp; ((1 &lt;&lt; 24) - 1)) / (1 &lt;&lt; 24); </code></pre> <p>Untested, but might work :-)</p>