Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Doesn't matter what your RAND_MAX is if you're taking the result modulo anything that's not a power of two.


No, it does matter. If RAND_MAX is really large, the relative error in "incorrect" probabilities is really small. Unless you have a critical need for it to be precisely correct, the error is basically negligible.


I have no idea what I was thinking, but I stand corrected. Thanks.


And if you have a need for it to be precisely correct, I have bad news for you about the word "random".




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: