windows - How are command prompt random numbers generated? -


in command prompt environment, there variable %random% uses algorithm generate pseudo-random numbers.

does know algorithm generates these numbers?

the %random% dynamic variable generates random number 0 32,767 inclusive. algorithm of these numbers generated this:

srand((unsigned)time(null)); 

it turns out windows command processor uses standard naïve algorithm seeding random number generator (quote here)

it spits out new number every second because of time seed.

as dbenham pointed out, 2 command prompts opened in same second output same exact numbers because of pseudorandomness , taking in of time seed.


Comments

Popular posts from this blog

PySide and Qt Properties: Connecting signals from Python to QML -

c# - DevExpress.Wpf.Grid.InfiniteGridSizeException was unhandled -

scala - 'wrong top statement declaration' when using slick in IntelliJ -