- #1
pairofstrings
- 411
- 7
Hello everyone.
I am investigating this method and trying to find how random numbers are getting generated.
Please look at the following code.
My intention is not trying to figure out how javasoft people wrote the code for this method. Maybe after reading my question, it might look as if I am trying to ask for the code in some sense, that's not my intention, at all.
Question is: What is Math.random() method code keeping track of, if the procossor is generating some random numbers. All I can see is my computer CPU is getting power from my house hold socket and I write the Math.random() method in my program and CPU generates some random numbers and they are displayed on the screen.
In broader sense, my question is something in the sense, where you can imagine a chemical reaction between two chemicals, which when combined, the atoms of the chemical combine and you get a different chemical, as a final product.
What is happening inside the processor which the Math.random() method written by javasoft people is keeping track of? Is there any particular mathematical function implemented in the Math.random() method, but it doesn't make any sense, if you think about it. Or is Math.random() method is keeping track of fluctuation in voltage, and the variations in electrical energy supplied to the processor!?
I know all of my assumptions are going to sound stupid after I get my answer.
I hope my question is clear. Thanks!
I am investigating this method and trying to find how random numbers are getting generated.
Please look at the following code.
Code:
class RandomNumbers{
public static void main(String[] args) throws InterruptedException{
int count=0;
while(true){
double d = Math.random();
System.out.println(d);
Thread.sleep(2000);
count++;
// Stop generating numbers when numbers generated are 20 in count
if(count==20){
System.exit(0);
}
}
}
}
My intention is not trying to figure out how javasoft people wrote the code for this method. Maybe after reading my question, it might look as if I am trying to ask for the code in some sense, that's not my intention, at all.
Question is: What is Math.random() method code keeping track of, if the procossor is generating some random numbers. All I can see is my computer CPU is getting power from my house hold socket and I write the Math.random() method in my program and CPU generates some random numbers and they are displayed on the screen.
In broader sense, my question is something in the sense, where you can imagine a chemical reaction between two chemicals, which when combined, the atoms of the chemical combine and you get a different chemical, as a final product.
What is happening inside the processor which the Math.random() method written by javasoft people is keeping track of? Is there any particular mathematical function implemented in the Math.random() method, but it doesn't make any sense, if you think about it. Or is Math.random() method is keeping track of fluctuation in voltage, and the variations in electrical energy supplied to the processor!?
I know all of my assumptions are going to sound stupid after I get my answer.
I hope my question is clear. Thanks!
Last edited: