In the command prompt environment, there is a variable %random%
that uses some algorithm to generate pseudo-random numbers.
Does anyone know the algorithm that generates these numbers?
The %random%
dynamic variable generates a random number from 0 to 32,767 inclusive. The algorithm of which these numbers are generated from is this:
srand((unsigned)time(NULL));
It turns out that the Windows command processor uses the standard naïve algorithm for seeding the random number generator (Quote from here)
It spits out a new number every second because of the time seed.
As dbenham pointed out, two command prompts opened in the same second will output the same exact numbers because of pseudorandomness and the taking in of time as a seed.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With