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
Check!
(thinking…)
Reset
or sign in with
  • facebook
  • google
    Password icon
    I agree to the terms of service
    Signed in as (Sign out)
    You have left! (?) (thinking…)
    Anonymous shared this idea  ·   ·  Flag idea as inappropriate…  ·  Admin →
    Anonymous shared a merged idea: Add "decimal" support to the standard C++ library  ·   · 

    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.

    7 comments

    Sign in
    Check!
    (thinking…)
    Reset
    or sign in with
    • facebook
    • google
      Password icon
      I agree to the terms of service
      Signed in as (Sign out)
      Submitting...
      • Andrew Pardoe [MSFT]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 BolstridgeAndy 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.

      • JeffJeff 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 WebbBrian 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.ista.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