jeudi 17 janvier 2019

How to find a proper mathematical function for a batch unix time random number generator?

From this article, I have determined how to generate infinite looping unix time for a batch file pseudo-randomization number generator. Here's the script;

@echo off
cls
color 0a
title TimeRandom
set div=1
setlocal

:setbound
cls
set /p lowbound=InputLowbound:
set /p maxbound=InputMaxbound:
goto :loopuntil

:loopuntil
cls
call :GetUnixTime utime
set /a varnum=%utime%+%div%/%div%
if %varnum% LEQ %maxbound% goto :chk

:continue
set /a div=%utime%*%div%
goto :loopuntil

:chk
cls
if %varnum% GEQ %lowbound% goto :result
goto :continue

:result
cls
echo Random Result
echo.
echo %varnum%
echo.
pause
goto :setbound


:GetUnixTime
setlocal enableextensions
for /f %%x in ('wmic path win32_utctime get /format:list ^| findstr "="') do (
    set %%x)
set /a z=(14-100%Month%%%100)/12, y=10000%Year%%%10000-z
set /a ut=y*365+y/4-y/100+y/400+(153*(100%Month%%%100+12*z-3)+2)/5+Day-719469
set /a ut=ut*86400+100%Hour%%%100*3600+100%Minute%%%100*60+100%Second%%%100
endlocal & set "%1=%ut%" & goto :EOF

Basically, at the line 17 and 21, I've tried numerous mathematical functions and still can't figure out the right function which is appropriate to use with this batch file considering the output time frame of no more than 10 seconds and generation of true pseudo-random numbers.




Aucun commentaire:

Enregistrer un commentaire