Sunday, July 31, 2022

Js why multiply the random for the number works

 You imagine that is magic but isn't, the Math.random() will return an number between 0 and 1, so you can't imagine how helpfull is this when you need to sort a number between o and 10000, intuitively you see that only could work, because you gonna multiply for 10000, so will appear something like 0,120638353..., but see if you need choice randomly the color the parameters are the top 255 for red 255 for blue and 255 for green, see if I gonna have a number betwen 0 and one so gonna be a '0' an decimal separator and a collection of numbers, see I will never gonna have a number higher than '1' isn't true? And say to me if a multiply 255 or any number for 1 I could have a number higher than 255? No. So a number that is 0,2323(something) how do you spect I have a number higher than 255? So I gonna have with the random multiply for 255 what you have between 0 to 255, and never a number higher. Rute Bezerra de Menezes Gondim



No comments:

Post a Comment