-
-
Notifications
You must be signed in to change notification settings - Fork 396
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
Round values like 1.239999 #8501
Comments
I think one of the apps sends these kind of numbers. I would be in favour of some rounding routine, say to one decimal. |
I think it should be relative… so 1 decimal or 1% of precision. |
It looks exactly like the result of converting from single precision floating point values, which have 24-bit fractional parts. We could cut off below 0.00000011920928955078125 (though maybe make it just a bit larger in case the ratio calculation itself introduces an error) times the value since that is the ratio between the values of the least and the most significant bits. I doubt it, but do any products have more precision? Alternatively, we might be able to detect special patterns in the binary representation in double-precision, which should show a long string of either 0s or 1s from a certain point (ignoring a few last significant bits- rounding errors might emerge there too). For example, double represents 0.40000000596046 as 3FD999999FFFFFAF, compared to the 0.4 which becomes 3FD999999999999A. This method should prevent genuine precise values form being rounded, but it might be overengineering. Wikipedia article on the single-precision floating-point format |
There's some code and some dicussion about this issue here: #3489 |
This issue has been open 90 days with no activity. Can you give it a little love by linking it to a parent issue, adding relevant labels and projets, creating a mockup if applicable, adding code pointers from https://github.com/openfoodfacts/openfoodfacts-server/blob/main/.github/labeler.yml, giving it a priority, editing the original issue to have a more comprehensive description… Thank you very much for your contribution to 🍊 Open Food Facts |
Dozens of thousands of products have weird values like 0.40000000596046, while it's printed 0.4 on the product:
And the corresponding values in the JSON file:
This does not lead to data quality errors' detection, but it's having annoying drawbacks for data quality:
More than 97,000 products are in this case (click on the [count] button).
As we never see values like this on the products, I would be in favor to automatically round these values.
The rule could be the following: any number containing more than 0000 or 9999 after the decimal separator should be rounded.
The text was updated successfully, but these errors were encountered: