+ 2

does srand generates a truly random no.

11th Oct 2016, 8:39 AM
Samarth Madan
Samarth Madan - avatar
4 Respostas
+ 2
No. To generate a truly random number, you would need to use an external source of randomness (like hardware noise). And then typically you would feed that one truly random number to srand() as a seed to generate a serie of pseudo-random numbers with rand(), because generating truly random numbers takes more time.
11th Oct 2016, 9:48 AM
Zen
Zen - avatar
+ 2
Zen.. that's actually an interested idea.. I didn't knew that you could "read" or "measure" hardware noise... but even then, as you said, it will still be pseudo-randomness, as the problem it's not the seed generation... the big problem is tha actual generator of "wanna be"-random numbers... in reality, what this generators give us is a very long (you could say infinite but this is also not true) list of apparently unordered numbers (unordered at least for the human eye)... but if you know the formula behind it, and analyze the pattern you could (at least in theory) "predict" the next outcomes... The seed just gives you a different starting point inside that list and perhaps a diferent "jumping" size.
11th Oct 2016, 11:14 AM
Nelson Urbina
Nelson Urbina - avatar
+ 1
No. With actual computing, true randomness doesn't exist. There is no algorithm or function that gives you a real random number. Maybe in future with quantum computing...
11th Oct 2016, 8:49 AM
marcram
- 1
yes.when u use only rand() each time u exécute ur prg u Will have the same randoms.srand((time)) change them
11th Oct 2016, 8:50 AM
boutheina