Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proper Random on Range #147

Open
ssell opened this issue Feb 24, 2017 · 0 comments
Open

Proper Random on Range #147

ssell opened this issue Feb 24, 2017 · 0 comments

Comments

@ssell
Copy link
Owner

ssell commented Feb 24, 2017

In ARandom::next the % operator is being used by itself to generate a value on the range of [0, (max - min)). According to this source, this is poor behavior. Which, now that it is presented to me, seems entirely accurate.

Update ARandom::next to retrieve values on a range using the suggested approach.

(int)((double)rand() / ((double)RAND_MAX + 1) * N)
@ssell ssell added this to the Ocular Engine v0.6 milestone Feb 24, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant