Math.random to generate negative numbers


Can I generate negative numbers using Math.random? If yes, how can I do this?


here it is

var r = Math.random() - 1


var r = -Math.random()


But be aware of the peculiarities in its _float_ing numbers, !!!
For instance


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.