absolute value. This will get a number
between 0 and 1. As the time changes every millisecond you won't risk to get the
same number
twice (when calculating them fast behind each other). If you want to calculate m
any
random numbers in a short time you should not use sin() alone. Then you would ge
t numbers
following a sine- curve! This is not really random. But if you want to calculate
a random
number and let's say in 20 seconds again- this is a great function to do this.
This is a random number:
Here is the code for this example:
<html>
<head>
<script language="JavaScript">
function RandomNumber() {
today = new Date();
num= Math.abs(Math.sin(today.getTime()));
return num;
</script>
|