vendredi 10 mai 2019

Generate random float, both bounds inclusive

I need to generate random real numbers in the range <-0.5; 0.5>, both bounds inclusive.

I found various ways to generate similar ranges, like

-0.5 + Math.random()

But the upper bound is always exclusive, I need it inclusive as well. 0.5 must be inside the range.




Aucun commentaire:

Enregistrer un commentaire