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

Overflow in rnd.next(long long, long long) #91

Open
viafanasyev opened this issue Oct 3, 2019 · 0 comments
Open

Overflow in rnd.next(long long, long long) #91

viafanasyev opened this issue Oct 3, 2019 · 0 comments

Comments

@viafanasyev
Copy link

When I try to run this line of code:
rnd.next(INT64_MIN + INT32_MAX - 1LL, INT64_MAX - INT32_MAX + 1LL)
I get the next error:
random_t::next(long long n): n must be positive.

It is caused by the implementation of next(long long, long long): it calls next(to - from + 1), but to - from + 1 is negative because of long long overflow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant