I suggest you ...

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.

98 votes
Vote
Sign in
(thinking…)
Sign in with: facebook google
Signed in as (Sign out)
You have left! (?) (thinking…)
Anonymous shared this idea  ·   ·  Flag idea as inappropriate…  ·  Admin →

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.

8 comments

Sign in
(thinking…)
Sign in with: facebook google
Signed in as (Sign out)
Submitting...
  • Anonymous commented  ·   ·  Flag as inappropriate

    The _Decimal types are being added as fundamental types to C. This is in TR24372. That doc is over 10 years old but received some attention recently, see n2095 dated October 2016, at http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2095.pdf. The GNU compiler supports these types via a GNU extension. I would like to see a similar extension for Visual Studio please.

    C++ development of a type that offers what you get with BigDecimal in java seems to be lagging. I reckon C will get there first and I think this is a good thing. Doing it in C first means the implementation will use support from the underlying hardware where available (BCD instructions are available since the 8086 days). Once we have it in C it should definately be in C++ also.

  • Andrew Pardoe [MSFT] commented  ·   ·  Flag as inappropriate

    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

  • Andy Bolstridge commented  ·   ·  Flag as inappropriate

    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.

  • Jeff commented  ·   ·  Flag as inappropriate

    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.

  • Brian Webb commented  ·   ·  Flag as inappropriate

    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.

  • ta.speot.is commented  ·   ·  Flag as inappropriate

    I'd -1 this if I could, if you want to change the standard C++ libraries give some feedback to the C++ standards comittee.

Feedback and Knowledge Base