Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

What's wrong with storing it as a float? I'm not saying you're wrong, I just genuinely don't know. If you could explain/point me to relevant literature I'd be grateful.


Some numbers with a finite representation in base 10, 0.2, for example, don't have a finite representation in base 2.

They are rounded, and doing arithmetic on such numbers leads to compounded rounding errors that you don't want to see when dealing with money.

Another problem is that the mantissa of floating point numbers is limited (52 bits for doubles), which can lead to truncated numbers, another big no no.


Storing BTC balances as floats is something a few services have done in the past so it makes sense to ask/bring up. Since BTC have 8 decimal precision, rounding can become noticeable very quickly even in addition and subtraction even though in real, today's value, it's not such a big deal.


http://stackoverflow.com/questions/3730019/why-not-use-doubl...

Also, all Bitcoin calculations are supposed to be done in integer Satoshis.


Quick Google, sorry it's easier than me offering an incomplete explanation: http://stackoverflow.com/questions/3730019/why-not-use-doubl...

And I really don't mean to pick on you, but that this isn't better known is why I worry when I see random sites popup offering financial services.


That's okay. I don't think I'm really representative anyway, as I'm not a professional/schooled programmer. Thanks for the link, I did try googling it myself but I didn't think to use the word "currency" so I just got a bunch of irrelevant results.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: