Comparing two double numbers
The following code executes the
else
statement because the
float
numbers are different
if (strval(0.000000000035436064) == strval(0.000000000035436064000001)) {
    echo 'if';
} else {
    echo 'else';
}
But if we add one
0
in front of the last digit of the second number, then
if
statement will be executed
if (strval(0.000000000035436064) == strval(0.0000000000354360640000001)) {
    echo 'if';
} else {
    echo 'else';
}
Note:
The above code is one of the best solutions to compare float numbers
by Valeri Tandilashvili
3 years ago
PHP
1
Pro tip: use ```triple backticks around text``` to write in code fences