Base-10 floating point data types

Is there any way (library, ecc.) to replace the float and double data types with other base-10 ones to avoid the floating point error?
There is C++ language extension for base-10 floating-point numbers, which became ISO standard in 2011 (but not as a part of C++11, it's a separate TR).

GCC supports it already: http://gcc.gnu.org/onlinedocs/libstdc++/libstdc++-api-4.5/a00850.html
> base-10 ones to avoid the floating point error?

An IEEE 754 base-10 floating point number is finite and inexact.
While 1.0/5.0 is representable exactly, 1.0/7.0 is not.
Last edited on
You can always just write your own Rational class.
@Cubbi How can I use those types? If I write std::decimal::decimal128 a; I get an error because for it std is the C++ Standard Library, not the GCC std. What can I do? (I have LLVM GCC 4.2)
If I write std::decimal::decimal128 a; I get an error

You would need gcc 4.6 or newer, and you need to #include <decimal/decimal>

Note that other compilers (intel, ibm) have had their own decimal floats for a long time, although with different syntax.
Does it make any difference the fact that I have the LLVM GCC? Or its 4.6 version will be good?
Topic archived. No new replies allowed.