samedi 16 novembre 2019

Generate double numbers between lowerBound and upperBound, with the value upperBound inclusive

I use the method:

public static double GenerateRandomDoubleValueBetweenLowerBoundAndUpperBound(double lowerBound, 
                                                                              double upperBound)
    {
        return rnd.NextDouble() * (upperBound - lowerBound) + lowerBound;
    }

The value upperBound itself is never generated. How can I modify the method to be able to generate the value upperBound inclusively? Thank you in advance.




Aucun commentaire:

Enregistrer un commentaire