I was using Math.random()*(max-min))+min
but this is all exclusive. How can I make it inclusive and what is the method behind figuring this out?
I tried Math.random()*(max-min))+min
until I realized that it was all exclusive. I'm trying to figure out the logic behind how to make this with the min inclusive. I also tried Math. random() * (max - min + 1) + min
but this makes the upper inclusive.
Simply stated: How can I use Math.random()
generate numbers from a minimum (inclusive) to a maximum (exclusive)?
Aucun commentaire:
Enregistrer un commentaire