I would like to generate a random number between x and y with the conditions (x, y] so x is excluded but y is included.
I am using Java.
I know that for the upper bound to be excluded it is Math.random
* y but what do you do for lower bound? I am not sure how you would do it this way because the Math.random function returns the opposite [0, 1) so I am not sure how you would inverse that.
I also took a link at this source for answers but I didn't get any luck. https://careerkarma.com/blog/java-math-random/#:~:text=The%20Math.,is%20always%20less%20than%201.
Please let me know
Aucun commentaire:
Enregistrer un commentaire