php-browser-detection
php-browser-detection copied to clipboard
Using Float datatype for version causes inaccuracy
It is inaccurate to use a float for versions. 17.10 is not the same as 17.1, but by using casting as a float they both appear as 17.1.
The issue is quite complicated.
This behavior is related to the way PHP handle floats.
PHP uses binary representation for floating point numbers (typically IEEE 754 format). In this format, some decimal fractions cannot be represented accurately. PHP automatically trims insignificant zeros after the decimal point. Thus, 17.10 becomes 17.1. When using functions like floatval(), PHP does not preserve information about the number of decimal places.
I need to figure out the best way to solve the issue.