vendredi 22 avril 2016

Not able to compare decimal variable after substracting

I am not able to compare after subtraction of 2 decimal numbers ,it will fail inside if statement

<?php

$current_bal = 1015279.83;
$unknown = 88931.17;
$bal= 926348.00;
$dummy = 926348.00;

$b= ($current_bal - $unknown);
echo $b;   //prints 926348.00;

if( $b == $bal){    //here it will not compare
    echo "match";
}

if($dummy == $bal){

    //here it matches since I assigned value directly in a variable

}

?>

Aucun commentaire:

Enregistrer un commentaire