logoalt Hacker News

jstanleytoday at 11:00 AM2 repliesview on HN

Yes it does. rdrand32()%65535 was my first attempt, and generated zeroes at about the expected rate, that's why I initially erroneously thought my CPU did not have this problem.


Replies

goaliecatoday at 11:04 AM

You should be using &0xFFFF for masking. Your mod is off by 1 too.

show 1 reply
RandomOnyxtoday at 11:01 AM

How about* rdrand32()%65536? Taking the remainder by 65535 doesn't take the lowest 16 bits after all

*: missed a word the first time around