I have this if condition :
if ($dc_real_vol != $dc_sum_vol) {
echo '||+++ REAL VOL ' . $dc_real_vol . PHP_EOL;
echo '||+++ SUM VOL ' . $dc_sum_vol . PHP_EOL;
echo '||+++ THIS TRADE IS DAMAGE ' . PHP_EOL;
}
when I checked the output :
||+++ REAL VOL 0.60533000
||+++ SUM VOL 0.60533
||+++ THIS TRADE IS DAMAGE
why PHP consider 0.60533000
as different with 0.60533
? how to make this condition marked as true?
update :
I tried solution from Loek below, and I changed my code like this :
$dc_real_vol = (float) $dc_real_vol;
$dc_sum_vol = (float) $dc_sum_vol;
echo '||*** REAL VOL ' . $dc_real_vol . PHP_EOL;
echo '||*** SUM VOL ' . $dc_sum_vol . PHP_EOL;
if ($dc_real_vol !== $dc_sum_vol) {
var_dump($dc_real_vol);
var_dump($dc_sum_vol);
echo '||+++ THIS TRADE IS DAMAGE ' . PHP_EOL;
}
and here's the result :
||*** REAL VOL 0.60533
||*** SUM VOL 0.60533
float(0.60533)
float(0.60533)
||+++ THIS TRADE IS DAMAGE
why same number, same type but PHP still recognised as different thing?