weixin_39574287
2021-01-07 13:12random.randrange and random.randint mishandle large ints
When a number larger than 2^31 - 1 is passed as the upper limit to random.randrange or random.randint, (with 0 as the lower limit, both implicitly and explicitly), those functions sometimes return a negative number. That's too obvious a "limit" to be coincidental. I've gotten it to consistently fail (more than .1% of the time) by adding just 10,000 to 2^31, but I bet it always breaks past that point and I just haven't let my tests run long enough.
该提问来源于开源项目:skulpt/skulpt
- 点赞
- 回答
- 收藏
- 复制链接分享
4条回答
为你推荐
- python随机产生0和1,得出F1-score的问题,求大神帮忙
- python
- 1个回答
- TypeError: unsupported operand type(s) for +: 'method' and 'method'
- python
- 1个回答
- 如何从范围中选择一个随机数?
- it技术
- 互联网问答
- IT行业问题
- 计算机技术
- 编程语言问答
- 2个回答
- Golang随机数发生器如何正确播种
- random
- 7个回答
- 同时写入和读取数组的最惯用方式
- io
- goroutine
- 2个回答
换一换