Precision

Feodor Pisnitchenko feodor@mat.ufpr.br
Thu Dec 18 23:11:00 GMT 2003


Hi all!
How can I find out the precision (mantissa length) of a floating point
number in i386 architecture?  
I don't understand the output the following program (why long double and
double have the same mantissa length?)

#include <iostream>
using namespace std;
int main() {
    float c3;
    double c2;
    long double c1;
c3=1.1234567890123456789012345678901234567890123456789012345678901234567890;
c2=1.1234567890123456789012345678901234567890123456789012345678901234567890;
c1=1.1234567890123456789012345678901234567890123456789012345678901234567890;
    cout.precision(50);
    cout << "long double c1 = " << c1 << "   " << sizeof(c1) << endl;
    cout << "     double c2 = " << c2 << "   " << sizeof(c2) << endl;
    cout << "      float c3 = " << c3 << "   " << sizeof(c3) << endl;
}

output:

long double c1 = 1.1234567890123456912476740399142727255821228027344   12
     double c2 = 1.1234567890123456912476740399142727255821228027344   8
      float c3 = 1.12345683574676513671875   4







More information about the Gcc-help mailing list