What is the Default Rounding for 8 digits in Binance,tradingview,etc

2

I have a problem. I am struggling to calculate programmatically the number of cryptocurrencies because I sometimes have inaccuracies in the last digit. Does anybody know what the problem is? (Of course, I have calculated the appropriate fees that need). For example, Binance uses accuracy for 8 Digits. What is the Rounding that they used? I would appreciate an answer if someone have the appropriate knowledge on this matter

RoundingMode.CEILING
RoundingMode.DOWN
RoundingMode.FLOOR
RoundingMode.HALF_DOWN
RoundingMode.HALF_EVEN
RoundingMode.HALF_UP
RoundingMode.UNNECESSARY
RoundingMode.UP

Panagiotis Drakatos

Posted 2018-05-09T14:30:51.143

Reputation: 143

I am currently debugging exactly the same behaviour as you describe in this issue. My balance for ETH does not add up if compared to my own calculations. At the moment, I assume that Binance does not credit the full amount of the deposit (e.g. 14 decimal places) to the account balance, but strips it to the precision they internally use (e.g. 8 decimal places). If I thereby apply RoundingMode.DOWN as rounding mode, my results become valid.

I am still looking to get any confirmation on that though. – croeck 2019-08-31T20:56:19.400

Answers

1

There should not be any rounding because all operations are integer operations. The 8 digits is because they calculate using the base unit of Bitcoin, the satoshi, which is 0.00000001 Bitcoin (8 digits). It is calculated as an integer (i.e. calculation uses satoshis, not Bitcoin) multiplied by an integer for the number of bytes, thus the result will also be an integer. The decimal then comes back as they shift the decimal point to represent the value in Bitcoin. There is no rounding involved, if there is, you are doing something wrong.

Andrew Chow

Posted 2018-05-09T14:30:51.143

Reputation: 40 910

Are you totally sure that Markets like Binance or Gdax.etc do the same calculation like this?Panagiotis Drakatos 2018-05-10T10:22:48.693

There is no reason not to do the calculation like this. If they do not do integer operations, then they introduce the possibility for floating point precision errors which can cause them to lost money for their customers.Andrew Chow 2018-05-10T15:21:31.883

Exchanges do have rounding errors.Evert 2019-02-22T17:29:33.830