Jump to content

Floating Point Random number generator with boundary

- - - - -

  • Please log in to reply
No replies to this topic

#1
hilarudeens

hilarudeens

    Newbie

  • Members
  • Pip
  • 2 posts
<?php
$result=fprand(10,15,2);
echo $result;

function fprand($intMin,$intMax,$intDecimals) {

if($intDecimals) {
$intPowerTen=pow(10,$intDecimals);
return rand($intMin,$intMax)+(rand(0,$intPowerTen)/$intPowerTen);
}
else
return rand($intMin,$intMax);
}




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users