vendredi 2 septembre 2016

Correctly using C rand for uniform values in the range of 0 and 1

Using the C standard library rand function for portable and correctly generating uniform random numbers of type double between 0.0 and 1.0 within the following ranges:

  • [0,1) ---> rand() / (RAND_MAX + 1.0)
  • [0,1] ---> ???
  • (0,1) ---> ???

What would be the correct ways for doing the last 2?

new C there are facilities for random. but i am interested in knowing how to use rand




Aucun commentaire:

Enregistrer un commentaire