Normally, when generating a number within a range, i've used this equation:
(Math.random() * (maximum - minimum)) + minimum;
However, now I need to generate a number between -100 and 100 inclusive. When using that equation, the number is always -100 since the random is multiplied by zero. No problem I found on this website dealt with that cancelling out to zero.
I need a solution that still uses Math.random(), as I am in AP Applications which requires us to use very specific terms when solving problems.
Aucun commentaire:
Enregistrer un commentaire