How to generate a real random number in C? -
I am trying to generate a random probability with maximum probability. How can we generate a random real value between 0 and 0.5 in C?
You can not generate actually portable number random at C99 but You can use some (and maybe with the present time) seeds.
And the computer does not know about true real numbers. Floating Point Only In fact I believe that the Universe does not know about real numbers (think of some cardinal logic). But ask physicists or philosophers.
There are PRNGs in some operating systems or implementations, and some systems (including hardware) are also real random generators.
Read more about; If your system has this also reads on Linux, then
you can try
double_my_random_number/ * between 0 and 0; 0.5 * / = drudge 48 () * 0.5;
Almost evenly distributed random numbers> = 0 and & lt; 0.5
If you accept the code in C ++, also see standard headers ...
Comments
Post a Comment