|
Question : "constant too big" error
|
|
VC6, SP3
I get the "error C2177: constant too big" when i do this:
long double d = 1e+309;
However i found in the help file that the range for long double is +/1.2E4932.
Microsoft Specific >
The long double contains 80 bits: 1 for sign, 15 for exponent, and 64 for mantissa. Its range is +/1.2E4932 with at least 19 digits of precision. Although long double and double are separate types, the representation of long double and double is identical.
END Microsoft Specific
What is the cause of my problem then?
|
|
Answer : "constant too big" error
|
|
Hi I think the Microsoft C/C++ compiler maps long double to type double.And that's the reason you are not able to assign a value greater than the max double value. Hope this helps. BYE VJ BTW, I found these in MSDN 1.) The long double data type (80-bit, 10-byte precision) is mapped directly to double (64-bit, 8- byte precision) in Windows NT and Windows 95.
2.) In 16-bit code, a long double is a native 80-bit type of the floating point processors in the Intel x86 microprocessor family. Because RISC processors do not have a native 80-bit floating point type, C and C++ compilers for Win32 platforms such as Microsoft Visual C++ implement this type as a 64-bit double. If you cannot tolerate the loss of precision of converting 80-bit long doubles to 64-bit doubles, then you should pass the 80-bit value as a structure consisting of two DWORDs (unsigned longs) and a WORD (unsigned short), and you will have to handle the value manually on the 32-bit side of the thunk.
|
|
|
|