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

Popular posts from this blog

OpenCV OpenCL: Convert Mat to Bitmap in JNI Layer for Android -

android - org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope -

python - How to remove the Xframe Options header in django? -