Back to index

php5  5.3.10
allowed_rounding_error.inc
Go to the documentation of this file.
00001 <?php
00002 function allowed_rounding_error ($number, $expected) {
00003 
00004        //different machines  may give slightly different floating point numbers
00005        //This assumes that the results will be the same to + or - 1.0E-10.
00006 
00007        $small_number = 1.0e-10;
00008        $min = $expected - $small_number;
00009        $max = $expected + $small_number;
00010 
00011        if ($number < $max  && $number > $min ) {
00012               return true;
00013        }
00014        else {
00015               return false;
00016        }
00017 }
00018 ?>