Is there a C++ equivalent to Java's BigDecimal?

后端 未结 8 1792
逝去的感伤
逝去的感伤 2020-11-27 19:42

I\'m looking for a C++ class that can do decimal floating point arithmetic. Looking through http://speleotrove.com/decimal/ there are links to all sorts of classes that peop

8条回答
  •  失恋的感觉
    2020-11-27 20:06

    Use GMP and store everything as cents. If you know that you won't pass 2^32 cents (42.949673 million dollars) use a 32 bit unsigned int (or use a 64 bit unsigned int) and keep it simple.

提交回复
热议问题