JavaScript generates 0~1 random decimals in a way that can call its own math.random ();
For example:
<script type= "Text/javascript" >document.write (Math.random ()); 0.5840498607140034</script>
There are rand,Mt_rand random methods in PHP, but neither of these methods generates 0~1 random decimals, and we can write a method to implement this function.
PHP generates 0~1 random decimal methods as follows:
<?php/** * Generate 0~1 random decimals * @param int $min * @param int $max * @return Float */function randfloat ($min = 0, $ Max=1) { return $min + Mt_rand ()/mt_getrandmax () * ($max-$min);} example, create 5 0~1 random decimals for ($i =0; $i <5; $i + +) { echo randfloat (). ' <br> ';}? >
Output:
0.598040262515680.677721965442280.905897512056820.450878588227030.17475316774787
JavaScript generates 0~1 random decimals in a way that calls its own math.random ();
For example:
<script type= "Text/javascript" >document.write (Math.random ()); 0.5840498607140034</script>
This article explains the generation of 0~1 random decimal method through PHP, more relevant content focus on PHP Chinese web.
Related recommendations:
Instructions for using MySQL timestamp format function from_unixtime
Instructions for using MySQL functions concat and Group_concat
Explanation of how MySQL InnoDB startup failure cannot be restarted