Vivaldo writes: > Dear Sir, > > I have found a difficult do work with long double. I have written a > simple test code and compiled it with gcc 4.0.0. The code was the following > > #include <cmath> > #include <iostream> > > using namespace std; > > main(){ > > long double x,y,a; > x = 1.000000000000001; //(1 at 15th decimal place) > y = 1.000000000000002; //(idem) > a = y - x; > cout.precision(30); > cout << a << endl; > } > > Surprinsingly, the output written in the screen was not > > 1.0000....e-15 > > with 19 correct decimal places. Instead the result was > > 8.88178419700125232338905334473e-16 > > with error at the 16-th place! > > How should I proceed to have the precision of 19 significative digits?
This list is not for general gcc enquiries, but for the development of gcc itself. Please address queries to gcc-help. This is not a bug. The type of a floating-point literal is double by default, not long double. See Section 2.13.3 of the C++ Standard, "floating literals" Andrew.