how do I make the cpu generate a true random number in javascript? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 4

how do I make the cpu generate a true random number in javascript?

Thanks in advance.

14th Feb 2017, 3:00 PM
Shahar Levy
Shahar Levy - avatar
3 Answers
+ 4
Technically there is no number that can be created by man or machine that is truly random. The best we can do is create functions so complex that they seemingly return random values, however they are never truly random. That being said there is the Math.random() method that will return a random number between 0 and 1 (non-inclusive). To generate random numbers between 0 and a higher limit just multiply Math.random() by the upper limit you want. example: var x = (Math.random() * 100) + 1 will give you a number between 1 and 100
14th Feb 2017, 3:12 PM
Sean Kudebeh
Sean Kudebeh - avatar
+ 4
There is a seed function in C++ that helps generate a True random number using the internal clock as a seed. It means that the cpu generates a number based on the seed from the clock, which is always changing, hence giving a different number each time - That is what true random means. Question is, how can I do it in javascript. And the random functions of Java and C# are also giving true randoms numbers.
16th Feb 2017, 7:32 PM
Shahar Levy
Shahar Levy - avatar
0
всем привет.кто знает как создать скрипт троян???
16th Feb 2017, 6:46 PM
Roman
Roman - avatar