Native currency qty vs raw inaccurate

+2 votes

Hi Multichain folks,

I have issued a native asset 10,000,000,000 units with up to 4 decimal places. After a few transactions I can see this balance at 1 address:

[
    {
        "assetref" : "",
        "qty" : 9999999004.38669968,
        "raw" : 99999990043867
    }
]

why does the qty show many decimal places?

asked Apr 25, 2018 by StevenChan
Please clarify which version of MultiChain you are using?
I'm using MultiChain 1.0.1 Daemon (protocol 10009)
Thanks and sorry for delay. The dev team is taking a look.

1 Answer

+1 vote
So the answer came back that MultiChain 1.0 uses eight decimal places for floating point numbers in JSON responses. In your case here there are so many digits before the decimal place that you're reaching the limit of floating point accuracy. Your best option is simply to round as appropriate on the application level.
answered Apr 30, 2018 by MultiChain
It's unfortunate that native currency displays to eight decimal places even though I have set the native-currency-multiple = 10000.

Together with JS Number precision limitations, this seems to mean that I can only accurately rely on qty if the number has seven or less digits before the decimal place?
In the case you have here, you can just round it to four decimal places, since you know the units of this asset. Or make use of the raw quantity.
...