note 74824 deleted from function.rand by felipe

[email protected]
Newsgroups php.notes
Message-ID <[email protected]>
Note Submitter: blackened at live dot com 

----

DKDiveDude forgot one thing in his function.
I tested it, and I found out the random output could even be smaller then $intMin.
This was because he forgot to multiply $intMin with $intPowerTen.
Below DKDiveDude's function with the edit

<?php
// Floating point random number function
// April 2007, René W. Feuerlein
function fprand($intMin,$intMax,$intDecimals) {
  if($intDecimals) {
    $intPowerTen=pow(10,$intDecimals);
    return rand($intMin*$intPowerTen,$intMax*$intPowerTen)/$intPowerTen;
  }
  else
    return rand($intMin,$intMax);
}
?>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.