I wrote a simple program (actually trying to implement a linear congruent generator), but I'm not quite sure that it works as it should.
I wanted to create 250 numbers from [0,1] using my generator. However, it seems that instead of random numbers, I get equal values.
How to improve it / what have I done wrong?
Here is the code:
#include <iostream>
And the conclusion:
0.00025194 0.000252278 0.000252279 0.000252279 0.000252279 0.000252279
Switching to int instead of double , however, gives good results:
#include <iostream>
Conclusion:
8 43 218 1093 5468 27343 136718 683593 3.41797e+06 1.70898e+07 8.54492e+07 4.27246e+08 2.13623e+09 2.09122e+09 1.86615e+09 7.40836e+08 -5.90786e+08 1.34104e+09 ...
But I need this to generate random double numbers, greater than or equal to 0 and less than or equal to 1: (
source share