Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-33026

Support for the C++ decimal floating-point types (for "decimal floating point arithmetic")

    XMLWordPrintable

Details

    • Suggestion
    • Resolution: Unresolved
    • P4: Low
    • None
    • 5.1.0
    • Core: Other
    • None

    Description

      The support in C++ for decimal floating-point types is [ongoing](http://www.open-std.org/jtc1/sc22/wg21/docs/projects#24733), and nowadays there is already enough support to compile very useful code in GCC.

      Those capabilities of decimal floating-point types are also supported [in the Intel compiler](http://software.intel.com/en-us/forums/topic/289019).

      Using GCC 4.7.3, those are examples of those useful capabilities, available nowadays:

      1) If developers use a decimal type, they achieve that programs don't get stucked in some loops:

      main.cpp
      #include <iostream>   
      #include <decimal/decimal>   
      
      using std::decimal::decimal32;
      using std::cout;
      using std::endl;
      
      int main() 
      {
          decimal32 dec;     
          
          cout << "What about decimal32?" << endl;
          for (dec = 1.1df; dec != decimal32(1.5df); dec = dec + decimal32(0.1df))
          {
              ;   // In that place there would be code that would work with the "dec" variable
          }
          cout << "    decimal32 is ok." << endl;
          
          double doub;     
          
          cout << "What about double?" << endl;    
          for (doub = 1.1; doub != 1.5; doub = doub + 0.1)
          {
              ;   // In that place there would be code that would work with the "doub" variable
          }
          // "doubles" are not good enough for this, the program gets stucked, and never arrives there
          cout << "    double is ok." << endl;
          
          return 0;
      }        
      

      2) If developers use a decimal type, they achieve that quantities related to money, and quantities that are read or written by humans, are calculated and presented correctly.

      3) Etc.

      So the next step is that Qt can work with those decimal types, too, so for example
      QString::number(aDecimalNumber);
      works

      Thanks for all!

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            Unassigned Unassigned
            ganton Ganton
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes