note 100294 modified in language.types.float by danbrown
| From: | danbrown@php.net | Date: | Wed, 06 Oct 2010 14:42:17 +0000 |
| Subject: | note 100294 modified in language.types.float by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-173004@lists.php.net to get a copy of this message | ||
Small float compare function
<?php
function floatcmp($a,$b,$decimals=6) {
return
sprintf('%01.'.$decimals.'f',$a)==sprintf('%01.'.$decimals.'f',$b);
}
?>
--was--
Small float compare function
function floatcmp($a,$b,$decimals=6) {
return
sprintf('%01.'.$decimals.'f',$a)==sprintf('%01.'.$decimals.'f',$b);
}
http://php.net/manual/en/language.types.float.php