|Welcome to the Monastery|
Re: rand() precision low, looking for a fast way to get high precision rand float?by BrowserUk (Pope)
|on Oct 31, 2012 at 17:15 UTC||Need Help??|
I want if() to be true at a rate of 1/40.000, however, rand() is not precise enough and outputs 0 quite often
That's not the way random works. It doesn't guarantee 1/40000, if it did, it would not be "random".
It only guarantees that the ratio will tend towards 1/40000 over time.
Most times it will produce 1/40000; but sometimes it will be 0/40000; sometimes 2/40000; occasionally 3/40000; very occasionally even 4/40000; but over time they will tend to balance each other out and the ratio will tend to get closer and closer to 1/40000.
Try running this for a while to see how it works:
If you need to always get one true from every 40,000, then use:
With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.