The following code generates a double number in the range [0,1) which means that 1 is exclusive.
var random = new Random();
random.NextDouble();
I am looking for some smart way to generate a random double number in the range [0,1]. It means that 1 is inclusive. I know that the probability of generating 0 or 1 is really low, but imagine that I want to implement a correct mathematical function that requires from me the inclusive limits. How can I do it?
The question is: What is the correct way of generating random in the range [0,1]. If there is no such way, I would love to learn it also.
Aucun commentaire:
Enregistrer un commentaire