I want to compare two floats in PHP, like in this sample code:
$a = 0.17; $b = 1 - 0.83; //0.17 if($a == $b ){ echo \'a and b are same\'; } else { echo \'a
For PHP 7.2, you can work with PHP_FLOAT_EPSILON ( http://php.net/manual/en/reserved.constants.php ):
if(abs($a-$b) < PHP_FLOAT_EPSILON){ echo 'a and b are same'; }