While making the calculation with float variable one should really careful since there can be three cases, It can < or > or =. So lets see the example below and learn how to get the comparative.
$varOne = round(0.250, 3);
varTwo = round(1 - 0.750, 3); //0.250
if($varOne == $varTwo ){
echo 'varOne and varTwo are same variable';
}
else {
echo 'varOne and varTwo are not same variable';
}
But I'll suggest always make 3 or 4 decimal digits in case of float comparison.
0 Comment(s)