Skip to content
This repository has been archived by the owner on Jul 19, 2024. It is now read-only.

precision issues in counterwallet/counterwalletd #21

Open
robby-d opened this issue Apr 3, 2014 · 1 comment
Open

precision issues in counterwallet/counterwalletd #21

robby-d opened this issue Apr 3, 2014 · 1 comment
Labels

Comments

@robby-d
Copy link
Contributor

robby-d commented Apr 3, 2014

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).
@robby-d robby-d added this to the Counterwallet 1.1 milestone Apr 3, 2014
@robby-d robby-d added the bug label Apr 3, 2014
@robby-d robby-d modified the milestones: 1.1, 1.3 Apr 20, 2014
@robby-d robby-d modified the milestones: Sprint 4, Sprint 3 May 7, 2014
@robby-d robby-d removed this from the Sprint 4 milestone Jun 16, 2014
@unsystemizer
Copy link
Contributor

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).

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants