+ 3
What does Math.floor(Math.random() ); combination do..
I have seen this a lot of times here .. and I have tried combining Math.Ceil(Math.random() ) Math.round(Math.random() ) Math.atan(math.abs() ) etc I don't even know if this is right. .I tried all the Maths() functions and none of them works except the Math.floor(Math.random() ) can anyone try explaining all these maths combining mybe even the rest.. THANK YOU..
1 Odpowiedź
+ 4
Math.floor(Math.random()) will always return 0 as Math.random is a randomly chosen number between 0 and 1, and you're asking for the greatest integer <= your number using Math.floor.
For the same reason, Math.ceil(Math.random()) will always return 1 because Math.ceil gives you the lowest integer >= your number.
However, Math.round(Math.random()) will give you 0 half of the time, and 1 the rest.