@
GokAy I used the random number function SS64 used
here. They use a function like,
Code:
[I]f(min, max) = floor(randint(0, 32767) * max / 32768) + min[/I]
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 :huh:.
For example, try
f(50, 100)
Code:
set /a rand=%RANDOM%*100/32768+50
It tends to return numbers greater than 100 fairly often.
The same thing happens with your function, Gokay, of,
Code:
[I]f(min,max) = randint(0, 32767) % 244 + 10[/I]
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).
Here are the corrected functions,
Code:
[I]f(min, max) = floor(randint(0, 36727) * (max-min+1) / 32767) + min[/I]
and
Code:
[I]f(min, max) = rand(0, 36727) % (max-min+1) + min[/I]
which translates into Batch as
Code:
set /a rand=%RANDOM% * (%MAX%-%MIN%+1) / 32768 + %MIN%
and
Code:
set /a rand=%RANDOM% %% (%MAX%-%MIN%+1) / 32768 + %MIN%
respectively.
I guess I'll be using the above line to retrieve random numbers when in Batch from now on.
[...] (single % before 244 instead of %% in script)
Other way 'round. Double percent in script, single percent on command line.
This is the original script
netsh interface ip set address name="Wireless Network Connection" static 192.168.1.64 255.255.255.0 192.168.1.254;
its supposed to change any variable inbetween each dot within each address
For example?