Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using Float datatype for version causes inaccuracy #29

Open
marzvrover opened this issue Mar 24, 2024 · 1 comment
Open

Using Float datatype for version causes inaccuracy #29

marzvrover opened this issue Mar 24, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@marzvrover
Copy link

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.

@foroco
Copy link
Owner

foroco commented Sep 3, 2024

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.

@foroco foroco added the bug Something isn't working label Sep 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants