Login   Register  
PHP Classes
elePHPant
Icontem

File: generate_random_float_numbers_class.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Ovunc Tukenmez  >  Generate random float numbers  >  generate_random_float_numbers_class.php  >  Download  
File: generate_random_float_numbers_class.php
Role: Class source
Content type: text/plain
Description: Class file
Class: Generate random float numbers
Generate random floating point numbers
Author: By
Last change: -
Date: 2008-05-14 09:54
Size: 530 bytes
 

Contents

Class file image Download
<?php
class generate_random_float_numbers
{
    public 
$generated_numbers = array();

    function 
__construct($total$how_many)
    {
        
$i 0;
        while (
$i != $how_many) {
            if (
$i == $how_many 1) { $this->generated_numbers[count($this->generated_numbers)] = $total; } else {
                
$this->generated_numbers[count($this->generated_numbers)] = round(lcg_value() * intval($total rand(1rand(2$how_many $i))), 2);
                
$total -= $this->generated_numbers[count($this->generated_numbers) - 1];
            }
            
$i++;
        }
    }
}
?>