Skip to content

Instantly share code, notes, and snippets.

@bestimmaa
Forked from hfadev/random.c
Last active December 31, 2015 14:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bestimmaa/8002601 to your computer and use it in GitHub Desktop.
Save bestimmaa/8002601 to your computer and use it in GitHub Desktop.
Generating a random float between 0 and 1
//set seed
srand(time(NULL));
// random number in range [0,1]
float r = (float)rand()/RAND_MAX;
printf("%f\n", r);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment