New
#11
@GokAy I used the random number function SS64 used here. They use a function like,
I tested with different max and min values and I found that with some pairs of max and min the function returns numbers greater than the max. Though their example of f(0,500) seems to work OK .Code:f(min, max) = floor(randint(0, 32767) * max / 32768) + min
For example, try f(50, 100)
It tends to return numbers greater than 100 fairly often.Code:set /a rand=%RANDOM%*100/32768+50
The same thing happens with your function, Gokay, of,
it occasionally generates numbers greater than the given max, 244. Again, this is more apparent if you pass in numbers more closer to each other, e.g. f(50, 100).Code:f(min,max) = randint(0, 32767) % 244 + 10
Here are the corrected functions,
andCode:f(min, max) = floor(randint(0, 36727) * (max-min+1) / 32767) + min
which translates into Batch asCode:f(min, max) = rand(0, 36727) % (max-min+1) + min
andCode:set /a rand=%RANDOM% * (%MAX%-%MIN%+1) / 32768 + %MIN%
respectively.Code:set /a rand=%RANDOM% %% (%MAX%-%MIN%+1) / 32768 + %MIN%
I guess I'll be using the above line to retrieve random numbers when in Batch from now on.
Other way 'round. Double percent in script, single percent on command line.
For example?