N
N
nonbody2015-05-23 11:57:04
PHP
nonbody, 2015-05-23 11:57:04

How to generate decimal random number in php?


openoffice and Microsoft Excel have a rand () function that outputs a decimal number in the range from 0 to 1 with several numbers after the decimal point, for example
: 0,6897044908 0,0568304828 0.37267139228 0,070451943 0,3893534059 0.3117308363 0,5107350638 0,2798799935 0,27987401 0,9782965942 0,1683965942 0,1683980518 0,1683980518 0,5100638252 How to make the same in PHP? mt_rand(0,1) only prints 0 or 1, but just mt_rand() prints whole numbers.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir Martyanov, 2015-05-23
@vilgeforce

Two parameters - the range in which the random number should be, everything is correct. Divide the result of mt_rand() by MAX_RAND and get from zero to one.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question