bitshares / bitshares1-core

Software to run the old chain (before 2015-10-13). Code for current chain is https://github.com/bitshares/bitshares-core
https://bitshares.org/
The Unlicense
219 stars 174 forks source link

Attempt to transfer 5120.9 resulted in transfer of 5120.8999999 #671

Closed nikakhov closed 9 years ago

nikakhov commented 10 years ago

https://github.com/BitShares/web_wallet/issues/221

vikramrajkumar commented 10 years ago

Due to parsing input as floating point. Should be addressed to help prevent dust.

nathanielhourt commented 10 years ago

I don't think this is due to floating point parsing; I think this is an inherent limitation of the fixed-point representation we use in the backend. This is a known limitation, and unfortunately we don't have any plans to fix this at present.

vikramrajkumar commented 10 years ago

Actually this is not due to price computations like #792 seems to be, as this was a straight asset transfer with the input parsed as a double from the command line and then converted to an asset. There should be no floats anywhere near our asset code and in fact we should probably really be representing assets and prices as rationals using an established library like GMP: https://gmplib.org/

vikramrajkumar commented 10 years ago

In Python:

>>> 5120.9 * 100000
512089999.99999994
vikramrajkumar commented 10 years ago

Progress: https://github.com/BitShares/bitshares_toolkit/commit/51629cd16bf3c8d2f95c3de8b1e21adc2e3d3786

nathanielhourt commented 9 years ago

This is now fixed. It was due to processing the input as a double and doing math on it. Doubles are no longer used anywhere in user input processing of market orders.