08.07.2016, 15:23
i can simply tell with example
random(2) gives two possible outputs 0 and 1 that means random(x) gives 0 to x-1 numbers
so to find range of random the programm should be like this
random(upperlimit-lowerlimit+1)+lowerlmit
for eg in this case for finding the random in range 20 to 60 seconds
it should be like this
random(60000-20000+1)+20000
or
random(40000+1)+20000
random(40000) will only give values up to 39 seconds and that plus 20 gives 59(maximum possible) not 60
so to get 60 we adds 1 to it
random(40001)+20000 give MAX-60000 or 60 seconds and MIN-200000 or 20 seconds
random(2) gives two possible outputs 0 and 1 that means random(x) gives 0 to x-1 numbers
so to find range of random the programm should be like this
random(upperlimit-lowerlimit+1)+lowerlmit
for eg in this case for finding the random in range 20 to 60 seconds
it should be like this
random(60000-20000+1)+20000
or
random(40000+1)+20000
random(40000) will only give values up to 39 seconds and that plus 20 gives 59(maximum possible) not 60
so to get 60 we adds 1 to it
random(40001)+20000 give MAX-60000 or 60 seconds and MIN-200000 or 20 seconds