Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

php random float number with 2 decimal places

$decimals = 2; // number of decimal places
$div = pow(10, $decimals);

// Syntax: mt_rand(min, max);
mt_rand(0.01 * $div, 0.05 * $div) / $div;
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #php #random #float #number #decimal #places
ADD COMMENT
Topic
Name
6+4 =