i am reading high quality 16 bit random numbers of type uint16_t from /dev/random and i am getting numbers as big as: 2936814755. Are these correct
int myFile = open("/dev/random", O_RDONLY);
unsigned int rand;
uint16_t randomNum = read(myFile, &rand, sizeof(rand)) ;
printf(" %u ", rand);
close(myFile);
unsigned int probably isn't 16 bit on your pc architecture. If you want to be sure use uint16_t instead.
uint16_t rand;
int ret = read(myFile, &rand, sizeof(rand)) ;
I think you were confusing the return value of read (ret that should be int and is the numbers of bytes read) and the generated random number (rand that should be uint16_t and is the random number generated).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With