module random: randint() range error #17935
Replies: 4 comments
-
The maximum range should be documented. |
Beta Was this translation helpful? Give feedback.
-
Yes, it should be documented as -2³¹+1 … 2³¹ - 1. One could then calculate: |
Beta Was this translation helpful? Give feedback.
-
Actually is is documented: https://docs.micropython.org/en/latest/genrst/modules.html#random |
Beta Was this translation helpful? Give feedback.
-
How true. But I agree, if the full range is needed (or a multiple on 2ⁿ), in other word for 32 in 4 billion cases, than that's the way to go. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Port, board and/or hardware
rp2
MicroPython version
MicroPython v1.26.0 on 2025-08-09; Raspberry Pi Pico with RP2040
The upper limit of the randint(a,b) doesn't behave as described in the documentation.
Reproduction
Expected behaviour
Expected to work up to the upper limit of 2³² - 1
Observed behaviour
Additional Information
No, I've provided everything above.
Code of Conduct
Yes, I agree
Beta Was this translation helpful? Give feedback.
All reactions