LDBL_MAX cannot Obtain


I could not obtain anymore the right value for the
Maximum Value of a Long Double using the LDBL_MAX definition...

1
2
3
cout << "The maximum value of a long double is " <<  LDBL_MAX << endl;

I get something like  -1.#QNAN 


My Compilation is a success.....

General: MinGW GCC 4.8.1 32-bit Release
Executing g++.exe...
g++.exe "D:\Temp\MaxValDataType.cpp" -o "D:\Temp\MaxValDataType.exe" -I"C:\Program Files (x86)\Dev-Cpp\MinGW32\include" -I"C:\Program Files (x86)\Dev-Cpp\MinGW32\mingw32\include" -I"C:\Program Files (x86)\Dev-Cpp\MinGW32\lib\gcc\mingw32\4.8.1\include" -I"C:\Program Files (x86)\Dev-Cpp\MinGW32\lib\gcc\mingw32\4.8.1\include\c++" -L"C:\Program Files (x86)\Dev-Cpp\MinGW32\lib" -L"C:\Program Files (x86)\Dev-Cpp\MinGW32\mingw32\lib" -static-libstdc++ -static-libgcc
Compilation succeeded in 2.64 seconds



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// A program to show the maximum and minimum values of various data types.

#include <iostream>
#include <climits>  // max & min size of integer types
#include <cfloat>  // max & min size of real types

using namespace std;

/**
* Print out the extreme values of various integer types.
*/

int main() {
cout << "The maximum value of a short is " << SHRT_MAX << endl;
cout << "The minimum value of a short is " << SHRT_MIN << endl;
cout << "The maximum value of an int is " << INT_MAX << endl;
cout << "The minimum value of an int is " << INT_MIN << endl;
cout << "The maximum value of a long is " << LONG_MAX << endl;
cout << "The minimum value of a long is " << LONG_MIN << endl;
// long long values might not exist on some computers
cout << "The maximum value of a long long is " << LLONG_MAX << endl;
cout << "The minimum value of a long long is " << LLONG_MIN << endl;

cout << "The minimum positive value of a float is " << FLT_MIN << endl;
cout << "The minimum epsilon value of a float is " << FLT_EPSILON << endl;
cout << "The maximum value of a float is " << FLT_MAX << endl;
cout << "The minimum positive value of a double is " << DBL_MIN<< endl;
cout << "The minimum epsilon value of a double is " << DBL_EPSILON << endl;
cout << "The maximum value of a double is " << DBL_MAX << endl;
// long double might not be defined on some systems
cout << "The minimum positive value of a long double is " << LDBL_MIN<< endl;
cout << "The minimum epsilon value of a long double is " << LDBL_EPSILON << endl;
cout << "The maximum value of a long double is " <<  LDBL_MAX << endl;

return 0;
}







I don't think long double was a standard type in C++03. Try if compiling the code in C++11 mode (-std=c++11) makes any difference.
Topic archived. No new replies allowed.