$sum=(0.5+0.2+0.2+0.1);//var_dump float(1)$sum2=1 //var_dump int(1)$sum == $sum2 //var_dump bool(false)
What's the matter, please?
In addition, the following tests are possible.
For example
(0.5+0.2+0.3+0.0)==1 //var_dump bool(true)
Reply content:
$sum=(0.5+0.2+0.2+0.1);//var_dump float(1)$sum2=1 //var_dump int(1)$sum == $sum2 //var_dump bool(false)
What's the matter, please?
In addition, the following tests are possible.
For example
(0.5+0.2+0.3+0.0)==1 //var_dump bool(true)
When calculating numbers, use Bcmath (point me to point me)
php
var_dump(bcadd(0.1+0.001));var_dump(0.1+0.001);
The method of binary representation of decimal in the computer results in inaccurate accuracy
All the languages are like this decimal is more commonly used
ABS (expression) < 1e-14 (or other than very small number)
One is a float point, one is an integer, as for the following to understand the PHP source code in depth
This is the problem of floating point accuracy, which exists in all languages and is explained in the PHP Documentation: link Address
The classic question depends on the explanation of the great God.
Http://www.laruence.com/2013/03/26/2884.html