why does pyb.rng() provide only 30 bits of the 32-bit hardware random number generator?
hal rng.c shifts off lower 2 bits HAL_RNG_GetRandomNumber(&RNGHandle) >> 2
This app note on NIST tests of STM32Fxx random number generator doesn't report any problems?
http://www.st.com/web/en/resource/techn ... 073853.pdf
inquiring minds want to know ...
pyb.rng() why 30 bits?
Re: pyb.rng() why 30 bits?
If I had to guess I would say that it because at the time the rng code was written, MicroPython probably only supported small ints, which are 31-bit signed, or 30-bit unsigned numbers.
Now that there is multi-precision integer support, rng can probably be reworked to support the full 32-bits.
Now that there is multi-precision integer support, rng can probably be reworked to support the full 32-bits.
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
Re: pyb.rng() why 30 bits?
Perhaps it should stay at 30 bits to ensure it can be called from within an interrupt handler.
Peter Hinch
Index to my micropython libraries.
Index to my micropython libraries.