For floating point number comparison, the manual does not understand; $ a & nbsp; 1.11; $ B & nbsp; 1.11; if ($ a $ B) {The result is true.} isn't it true that two floating point numbers are equal? What does it mean? cannot the calculated floating point numbers be compared? & Nbsp; ------ solution ---------------------- it is not to say that we should not compare, but that the manual does not understand the accuracy of the comparison of floating point numbers;
$ A = 1.11;
$ B = 1.11;
If ($ a = $ B ){
// The result is true;
}
Isn't it true that two floating point numbers are equal?
What does it mean? cannot the calculated floating point be compared?
------ Solution ----------------------
This is not to say that we do not want to compare, but because of the precision, the two seemingly identical numbers are not equal in comparison.
You can compare two numbers with the same precision. Of course there is no problem.
------ Solution ----------------------
It is not incomparable, but inaccurate.
For example:
$a = 1.1000000000000000001;
$b = 1.1000000000000000011;
if($a==$b){
echo 'equal';
}else{
echo 'not equal';
}
Output equal
------ Solution ----------------------
$ A = 1.00000000000000001;
$ B = 1.00000000000000002;
Var_dump ($ a = $ B); // bool (true) is actually equal
$ S = pack ('F', $ );
For ($ I = 0; $ I
Echo PHP_EOL;
$ S = pack ('F', $ B );
For ($ I = 0; $ I
Echo PHP_EOL;
They used to save the data in the computer.
00000000 00000000 10000000 00111111
00000000 00000000 10000000 00111111