<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/ref.random.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'en',
  ),
  'this' => 
  array (
    0 => 'function.lcg-value.php',
    1 => 'lcg_value',
    2 => 'Combined linear congruential generator',
  ),
  'up' => 
  array (
    0 => 'ref.random.php',
    1 => 'Random Functions',
  ),
  'prev' => 
  array (
    0 => 'function.getrandmax.php',
    1 => 'getrandmax',
  ),
  'next' => 
  array (
    0 => 'function.mt-getrandmax.php',
    1 => 'mt_getrandmax',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/random/functions/lcg-value.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.lcg-value" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">lcg_value</h1>
  <p class="verinfo">(PHP 4, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">lcg_value</span> &mdash; <span class="dc-title">Combined linear congruential generator</span></p>

 </div>

 <div id="function.lcg-value-refsynopsisdiv">
  <div class="warning"><strong class="warning">Warning</strong><p class="simpara">This function has been
<em>DEPRECATED</em> as of PHP 8.4.0. Relying on this function
is highly discouraged.</p></div>
 </div>

 <div class="refsect1 description" id="refsect1-function.lcg-value-description">
  <h3 class="title">Description</h3>
   <div class="methodsynopsis dc-description">
   <span class="attribute"><a href="class.deprecated.php">#[\Deprecated]</a> </span><br>
   <span class="methodname"><strong>lcg_value</strong></span>(): <span class="type"><a href="language.types.float.php" class="type float">float</a></span></div>

  <p class="para rdfs-comment">
   <span class="function"><strong>lcg_value()</strong></span> returns a pseudo random number in
   the range of (0, 1).  The function combines two CGs with periods
   of 2^31 - 85 and 2^31 - 249. The period of this function is equal
   to the product of both primes.
  </p>
  <div class="caution"><strong class="caution">Caution</strong>
 <p class="para">
  This function does not generate cryptographically secure values, and <em>must not</em>
  be used for cryptographic purposes, or purposes that require returned values to be unguessable.
 </p>
 <p class="para">
  If cryptographically secure randomness is required, the <span class="classname"><a href="class.random-randomizer.php" class="classname">Random\Randomizer</a></span> may be
  used with the <span class="classname"><a href="class.random-engine-secure.php" class="classname">Random\Engine\Secure</a></span> engine. For simple use cases, the <span class="function"><a href="function.random-int.php" class="function">random_int()</a></span>
  and <span class="function"><a href="function.random-bytes.php" class="function">random_bytes()</a></span> functions provide a convenient and secure <abbr title="Application Programming Interface">API</abbr> that is backed by
  the operating system’s <abbr title="Cryptographically Secure PseudoRandom Number Generator">CSPRNG</abbr>.
 </p>
</div>
  <div class="caution"><strong class="caution">Caution</strong>
   <p class="para">
    Scaling the return value to a different interval using multiplication
    or addition (a so-called affine transformation) might result in a bias
    in the resulting value as floats are not equally dense across the number
    line. As not all values can be exactly represented by a float, the
    result of the affine transformation might also result in values outside
    of the requested interval.
   </p>
   <p class="para">
    Use <span class="methodname"><a href="random-randomizer.getfloat.php" class="methodname">Random\Randomizer::getFloat()</a></span> to generate a
    random float within an arbitrary interval. Use <span class="methodname"><a href="random-randomizer.getint.php" class="methodname">Random\Randomizer::getInt()</a></span>
    to generate a random integer within an arbitrary interval.
   </p>
  </div>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.lcg-value-parameters">
  <h3 class="title">Parameters</h3>
  <p class="para">This function has no parameters.</p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.lcg-value-returnvalues">
  <h3 class="title">Return Values</h3>
  <p class="para">
   A pseudo random float value between 0.0 and 1.0, inclusive.
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-function.lcg-value-changelog">
  <h3 class="title">Changelog</h3>
  <table class="doctable informaltable">
   
    <thead>
     <tr>
      <th>Version</th>
      <th>Description</th>
     </tr>

    </thead>

    <tbody class="tbody">
     <tr>
      <td>8.4.0</td>
      <td>
       This function has been deprecated.
      </td>
     </tr>

    </tbody>
   
  </table>

 </div>


 <div class="refsect1 seealso" id="refsect1-function.lcg-value-seealso">
  <h3 class="title">See Also</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="methodname"><a href="random-randomizer.getfloat.php" class="methodname" rel="rdfs-seeAlso">Random\Randomizer::getFloat()</a> - Get a uniformly selected float</span></li>
    <li><span class="methodname"><a href="random-randomizer.getint.php" class="methodname" rel="rdfs-seeAlso">Random\Randomizer::getInt()</a> - Get a uniformly selected integer</span></li>
    <li><span class="function"><a href="function.random-int.php" class="function" rel="rdfs-seeAlso">random_int()</a> - Get a cryptographically secure, uniformly selected integer</span></li>
   </ul>
  </p>
 </div>

</div><?php manual_footer($setup); ?>