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
random.randint fails for some ranges #39962
Comments
I want a random 32-bit int and do it the obvious way: lowest, highest = int(-2**31), int(2**31-1) random.randint throws an exception: Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "/usr/lib/python2.2/random.py", line 349, in randint
return self.randrange(a, b+1)
File "/usr/lib/python2.2/random.py", line 328, in
randrange
raise ValueError, "empty range for randrange()"
ValueError: empty range for randrange() |
Logged In: YES It says "; current system time is also used to initialize Proposed new wording: ". When a new generator is |
Logged In: YES Oops, ignore previous comment, it was added to the wrong |
Logged In: YES This has been fixed for Py2.3.3 and 2.4 as a result of the In 2.2, it is still possible, but the call to int() inside As a workaround, generate two 16 bit integers and then join |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: