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

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

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

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