What is the correct type to use in Qt development (or C++ in general) for decimal arithmetic, i.e. the equivalent of System.Decimal struct in .Net?
- Does Qt provide a built-in struct? (I can’t find it in the docs, but maybe don’t know where to look.)
- Is there a “standard” C++ library to use?
Neither C++ standard library nor Qt has any data type equivalent to
System.Decimalin .NET.No.
No.
But you might want to have a look at the GNU Multiple Precision Arithmetic Library.
[EDIT:] A better choice than the above library might be qdecimal. It wraps an IEEE-compliant decimal float, which is very similar (but not exactly the same as) the .NET decimal, as well utilizing Qt idioms and practices.