note 100289 modified in language.types.float by danbrown
| From: | danbrown@php.net | Date: | Wed, 06 Oct 2010 14:44:49 +0000 |
| Subject: | note 100289 modified in language.types.float by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-173010@lists.php.net to get a copy of this message | ||
A simple way to check for equality of two floating point numbers. Change the default precision
according to your needs:
<?php
function IsFloatEqual($x,$y,$precision=0.0000001)
{
return ($x+$precision >= $y) && ($x-$precision <= $y);
}
?>
--was--
A simple way to check for equality of two floating point numbers. Change the default precision
according to your needs:
function IsFloatEqual($x,$y,$precision=0.0000001)
{
return ($x+$precision >= $y) && ($x-$precision <= $y);
}
http://php.net/manual/en/language.types.float.php