batch file - How to make %random% show up a negative result? -
i'm making game there stocks, , want them able go negative, know how limit positive random numbers, how %random% make negative value? and, making %random% generate negative numbers possible?
to produce random number in range minrand maxrand use
set /a selection=%random% %% (%maxrand% - %minrand% + 1) + %minrand% here's sampler : change values assigned minrand , maxrand test:
@echo off setlocal set /a minrand=-3 set /a maxrand=3 /l %%a in (1,1,20) call :genshow goto :eof :genshow set /a selection=%random% %% (%maxrand% - %minrand% + 1) + %minrand% echo %selection% goto :eof
Comments
Post a Comment