/* DemoDatatypes2.cpp CIS 150 5/26/2005 David Klick This program shows the range of the fp data types. The output will differ depending on what compiler is used. */ #include #include using std::cout; using std::endl; int main(void) { float n1 = 1.2E10; double n2 = 1.2E20; long double n3 = 1.2E20; cout << "A float is " << sizeof(float) << " bytes long\n"; cout << "A double is " << sizeof(double) << " bytes long\n"; cout << "A long double is " << sizeof(long double) << " bytes long\n"; cout << "float min: " << FLT_MIN << ", max: " << FLT_MAX << endl; cout << "double min: " << DBL_MIN << ", max: " << DBL_MAX << endl; return 0; } /* Sample output: A float is 4 bytes long A double is 8 bytes long A long double is 12 bytes long float min: 1.17549e-038, max: 3.40282e+038 double min: 2.22507e-308, max: 1.79769e+308 */