bigcompany/safewallet — pull request #4 by sevastos (2013-12-23 04:57:03+00:00)
Title: Loss of precision when deducting fees on deposits

A case of such precision loss occurs due to binary floating point rounding. In our case an example case is when a user's bitcoin balance has 0.059 or 0.05900001 BTC or similar, then the deduction of 0.0001 BTC fee happens which results to totals of 0.058899999999999994 and 0.058900009999999996 accordingly.

In order to solve this and be able to do precise calculations with a lot of decimals, I added a new NPM package: [bignumber.js](/MikeMcl/bignumber.js), let me know if you prefer something else.

About the test, I haven't managed to get couchdb running and couldn't figure out a quick way to have a unit test for this case with the structure of [lib/deposits/index.js](/bigcompany/safewallet/blob/master/lib/deposits/index.js), although I did a dirty refactoring locally to test it.
If you have any idea on making the test, let me know and I will prep the test.

-Sev