samedi 28 mars 2015

Is this way of generating random numbers safe and valid?

I was doing some recreational low-level programming the other day, and somewhere in my code this thing emerged (using pseudocode):


cointoss program



char out = '0';

void thread(){ out = '1';}

int main(){
// Creates a thread that will run the function we provided
// The main() will not wait for this thread to finish
runInOwnThread(thread);

printr("%d", out);
return 0;
}


Now in our shell we run cointoss program x number of times and we will end up with something like this:


0011011100001000


which we can convert to decimal and get a random number


My question is not whether this is an efficient way of creating a random number but more about we can tell if the end result is random enough for use





Aucun commentaire:

Enregistrer un commentaire