lcg_value


crypto apg

RETURNS returns a pseudo random number in the interval range of [ 0.0, 1.0 ].

LCG = Linear Congruential Generator.

   Linear congruential generator  !


Compatible with LOCALE only, up to PHP 7.4.XX.






The period of this function is equal to the product of the primes (2^31 - 85) and (2^31 - 249).

The result of this function does not generate cryptographically secure values, and should not be used for cryptographic purposes.

There are special functions for this.



<?php

float lcg_value 
()

?> 

  1 EXERCISE   

<?php

// Run this code several times

$lcgval01 lcg_value();

echo 
'The generated random number 
for this system in this moment, is: '
 
$lcgval01 '.<br><br>';
 
// setlocale(LC_ALL, 'pt-PT', 'pt_PT');
 
 
echo 'The generated random number 
for this system in this moment, is: '
 
$lcgval01 '.<br><br>';

?> 

  2 EXERCISE   

<?php

echo "MATHS test script started.";


echo 
"<br><br>lcg_value tests...<br>";
for (
$i 0$i 100$i++) {
    
$res lcg_value();

    if (!
is_float($res) || $res || $res 1) {
        break;
    }
}

if (
$i != 100) {
    echo 
"FAILED<br>";
} else {
    echo 
"PASSED<br>";
}

echo 
"MATHS test script completed<br>";

?>