Please add IEEE754:2008 decimal data types.
The Decimal standard type has 2 problems: It is HUGH (16 bytes) and it is SLOW. Now, often one does not need the size - then 16 bytes instead of 4 is a big price .And slow - well, as Decimal data types will get hardware support slowly.... the .NET type is basically outdated.
For compatibility leave it there and add Decimal32, Decimal64 and Decimal128, according to the IEEE specs.
I deal with a ton of smaller financial data. Floatings (float, double) - unusable. And spending 16 bytes for small numbers (that are stored as smallmoney in SQL server) gets expensive when you deal with millions of them.
Thank you for your suggestion! While we aim to respond to every suggestion, we are closing older ones that don’t have enough votes so newer ones from you can move to the top. If this suggestion is still important to you, feel free to open it again.
Andrew Pardoe [MSFT] commented
Thanks for your suggestion. Right now the MSVC team is focused on better conforming to the C++ Standard. We need to prioritize standardized work above work that is in TRs.
You can bring in the library from the TR yourself if you need to use it. And you should consider pushing the Standards Committee to address the deficit in the language if you want broad-based compiler support for the TR.
--Andrew Pardoe, MSFT VC++ team
Ben Voigt [Visual C++ MVP] commented
Support the similar proposal that's based in the actual Standard, instead. https://visualstudio.uservoice.com/forums/121579-visual-studio/suggestions/2433730-add-std-decimal-with-iso-iec-tr-24733-decimal-flo
Andy Bolstridge commented
Agreed, if you want a standard C++ decimal type, write one and submit it to Boost, or appeal to the C++ committee. In the meantime, use a 64-bit int, store pennies (or fractions of) in there.
I think this is a great idea.
Almost all languages support decimal floating point arithmetic.
Java by java.math.BigDecimal, Python by decimal.Decimal, Ruby by BigDecimal and .NET by System.Decimal which is also accessible in C# as decimal.
The document ISO/IEC TR 24733 specifies an extension for the programming language C++ to support decimal floating-point arithmetic.
Unfortunately, the Decimal TR (ISO/IEC TR 24733) was not accepted into C++11. However, there is already a proposal N3407 to add decimal floating point support to the C++ standard. The proposal indicates to accept it for C++17.
Hopefully Decimal TR (ISO/IEC TR 24733) will be provided by the C++ Standard Library shipped with Visual C++ as soon as possible.
The GNU C compiler already supports decimal floating types as defined in the N1312 draft of ISO/IEC WDTR24732.
Lars Wilhelmsen commented
Yeah, I agree - this is definitely a -1.
Brian Webb commented
Google C++ Decimal Struct. There are open source decimals that are structs. They are all integer based, with an N coefficient, which is what you want when you don't want a float.
Or use the .NET one in System.
I'd -1 this if I could, if you want to change the standard C++ libraries give some feedback to the C++ standards comittee.