← index #6718PR #13556
Related · high · value 0.149
QUERY · ISSUE

urandom.randint handling of >32bit values on 64-bit arch

openby jimmoopened 2020-12-22updated 2021-05-30
bugextmod

Noticed this while looking at https://github.com/micropython/micropython/issues/6712

>>> random.randint(0, 2**32)
0
>>> random.randint(0, 2**32-1)
(hangs)

On 32-bit platforms, both these examples would fail to convert the second argument to a small int (which I think is the correct behaviour for MicroPython).

On 64-bit though, they're valid small integers, but then there's an implicit conversion to uint32_t in yasmarang_randbelow.

I guess either we could use a 64-bit Yasmarang on 64-bit arch? Or add another check?

CANDIDATE · PULL REQUEST

Fix compilation warnings for Windows 64 bits

mergedby srinsozopened 2024-01-30updated 2024-02-15
extmod

Hi

Here is some missing cast and other minor change that prevent compilation warning if mp_int_t is defined as integer 64 bits.

Keyboard

j / / n
next pair
k / / p
previous pair
1 / / h
show query pane
2 / / l
show candidate pane
c
copy suggested comment
r
toggle reasoning
g i
go to index
?
show this help
esc
close overlays

press ? or esc to close

copied