$ A & quot; 1.2424 & quot; direct value $ b1.2424; read if (floatval ($ a) & amp; gt; $ B) {echo1;} from the mysql database float Field ;} I know that floating point numbers have precision issues and need to be compared through bccomp. However, can the above examples be compared directly? If not, please cite... $ a = "1.2424"; // assign a value directly.
$ B = 1.2424; // read from the mysql database float Field
If (floatval ($ a) >=$ B ){
Echo 1;
}
I know that floating point numbers have precision issues and need to be compared through bccomp.
However, can the above examples be compared directly? If not, give an example of failure.
Variables a and B are both directly assigned values. No operation is performed before and after the values are assigned, and they are directly compared by algorithm.
Reply content:
$ A = "1.2424"; // assign a value directly
$ B = 1.2424; // read from the mysql database float Field
If (floatval ($ a) >=$ B ){
Echo 1;
}
I know that floating point numbers have precision issues and need to be compared through bccomp.
However, can the above examples be compared directly? If not, give an example of failure.
Variables a and B are both directly assigned values. No operation is performed before and after the values are assigned, and they are directly compared by algorithm.
No.
Php-r "var_dump (1242.4/1000, floatval ('1. 100')> = 2424/1242.4);" float (1000) bool (false)