Random numbers in the POSIX C API

I am looking to create large non-negative integer random values ​​in a POSIX system. I found two possible functions that correspond to the account, and their respective initializers:

       #include <stdlib.h>

       long int random(void);    
       void srandom(unsigned int seed);
CONFORMING TO
       4.3BSD, POSIX.1-2001.

       // and

       long int lrand48(void);
       void srand48(long int seedval);    
CONFORMING TO
       SVr4, POSIX.1-2001.
  • What features are preferred (thread safety and range of generated values)?
  • Given that safety is not a concern, how should I plant them?
  • If sowing methods differ from each other due to different arguments for the sowing functions ( long intvs. unsigned int)?
+5
source share
1 answer

nrand48, , lrand48, , . , . ( , , glibc , . http://evanjones.ca/random-thread-safe.html , )

+3

All Articles