You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jul 19, 2024. It is now read-only.
Both counterwallet and counterwalletd convert from Decimal to float in several areas, between operations (and for storage). This is Not Good as precision is lost.
counterwalletd, specifically, does math in decimal, and then converts to float for storage in mongodb (as native Decimal storage is not supported, see https://jira.mongodb.org/browse/SERVER-1393). Instead, it should convert to string, and save, and then deserialize back into a Decimal on load. Another alternative is multiplying by 100M and serializing as an integer (pros of this is that is allows rapid sorting by the value in a DB query/filter).
This change will affect a lot, as even "normalization"/"denormalization" both in counterwallet and counterwalletd end up returning a float, after doing fixed point math and quantization.
---
Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/4062813-precision-issues-in-counterwallet-counterwalletd?utm_campaign=plugin&utm_content=tracker%2F542579&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F542579&utm_medium=issues&utm_source=github).
The text was updated successfully, but these errors were encountered:
MongoDB now supports "decimal128 data type, supporting decimal values with up to 34 digits of precision".
Maybe we should still check that this behavior is currently correct (the bug was filed years ago).
Both counterwallet and counterwalletd convert from Decimal to float in several areas, between operations (and for storage). This is Not Good as precision is lost.
counterwalletd, specifically, does math in decimal, and then converts to float for storage in mongodb (as native Decimal storage is not supported, see https://jira.mongodb.org/browse/SERVER-1393). Instead, it should convert to string, and save, and then deserialize back into a Decimal on load. Another alternative is multiplying by 100M and serializing as an integer (pros of this is that is allows rapid sorting by the value in a DB query/filter).
This change will affect a lot, as even "normalization"/"denormalization" both in counterwallet and counterwalletd end up returning a float, after doing fixed point math and quantization.
--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/4062813-precision-issues-in-counterwallet-counterwalletd?utm_campaign=plugin&utm_content=tracker%2F542579&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F542579&utm_medium=issues&utm_source=github).The text was updated successfully, but these errors were encountered: