What is the real code behind random function? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

What is the real code behind random function?

when we use or call random function we get a value btw 0 and 1 (in java) ..... but what is the original code written within that function which generates it... I googled and got something named PRNG from wiki which is complex to understand.... can anyone help me to explain what is written inside random function and how does it generate a number when we call it...??

20th May 2018, 7:38 AM
Sayantan Pal
Sayantan Pal - avatar
8 Answers
20th May 2018, 7:54 AM
Hatsy Rei
Hatsy Rei - avatar
+ 6
PRNG is an algorithm that uses a seed number(example: current millisecond) to generate a seemingly random number and uses that new number as seed to generate the next one. Check out this code and play with the values and see the result https://code.sololearn.com/Wq8uSyoVW3Wm/?ref=app
20th May 2018, 8:02 AM
Jonathan Pizarra (JS Challenger)
Jonathan Pizarra (JS Challenger) - avatar
+ 2
thnx it helped a lot 😊👌
20th May 2018, 8:05 AM
Sayantan Pal
Sayantan Pal - avatar
+ 2
int i; cout<<i; or char a; cout<<a; you will get random numbers and symbols...
20th May 2018, 9:07 AM
Arun
+ 2
Most pseudo random number generators use the group structure of elliptic curves to generate random looking numbers. The seeds that they use often come from a so called entropy pool, which on Linux is provided by the kernel and is created from different timings of things happening on the system, like different interrupt and so on
20th May 2018, 7:28 PM
Max
Max - avatar
+ 1
cool solution.... Thnx
20th May 2018, 8:01 AM
Sayantan Pal
Sayantan Pal - avatar
+ 1
The random class is an algorithm and is a pseudo generator.Its part of the MATH/Generator class.
21st May 2018, 5:10 PM
Apple Blossom
Apple Blossom - avatar
0
thks
20th May 2018, 8:42 AM
ifl
ifl - avatar