Details
-
Suggestion
-
Resolution: Unresolved
-
P4: Low
-
None
-
5.1.0
-
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:
#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!