Back to index

php5  5.3.10
Functions
allowed_rounding_error.inc File Reference

Go to the source code of this file.

Functions

 allowed_rounding_error ($number, $expected)

Function Documentation

allowed_rounding_error ( number,
expected 
)

Definition at line 2 of file allowed_rounding_error.inc.

                                                     {

       //different machines  may give slightly different floating point numbers
       //This assumes that the results will be the same to + or - 1.0E-10.

       $small_number = 1.0e-10;
       $min = $expected - $small_number;
       $max = $expected + $small_number;

       if ($number < $max  && $number > $min ) {
              return true;
       }
       else {
              return false;
       }
}