Intel® C++ Compiler
Support and discussions for creating C++ code that runs on platforms based on Intel® processors.
Announcements
Welcome to the Intel Community. If you get an answer you like, please mark it as an Accepted Solution to help others. Thank you!
7568 Discussions

Incompatibility between Visual C++ and Intel C++ regarding the long double type

meriko
Beginner
161 Views

Hello, 

I integrated the Intel C++ Compiler XE 2013 into Microsoft Visual Studio Professional Edition 2008 in order to be able to use long double data types with 80bit precision.

I used the /Qlong-double flag during compilation, and disabled all the optimizations available in Intel C++.

The program compiles and links without errors. However I observed that long double still doesn't work correctly.

When I print the following:

cout.precision(30);
cout<<std::numeric_limits<long double>::digits10<<endl;
cout<<std::numeric_limits<long double>::epsilon()<<endl;
cout<<sizeof(long double)<<endl;
cout<<std::numeric_limits<double>::digits10<<endl;
cout<<std::numeric_limits<double>::epsilon()<<endl;
cout<<sizeof(double)<<endl;

I get the following output:

18

-0 -->why??? 

16

15

2.2204460492503131e-016

8

Moreover, when I debug my code, I see that the types of my long double variables are unknown i.e. it shows ??? as the type instead of "long double". And when I set long double aa = 1.0; long double bb = 1e-18; the value of aa and bb are set to 0 and 2461398656 respectively. 

Can anyone help me with the problem? 

Thank you,

Meriko

0 Kudos
10 Replies
TimP
Black Belt
161 Views
"compatibllity" includes the use of Microsoft headers and libraries. This is documented in the description of /Qlong-double. The operand has to be cast implicitly to double for cout. I assume you use the debugging facility provided by Microsoft which also has no provision for a long double differing from double.
meriko
Beginner
161 Views
Does Intel C++ compiler have its own runtime library? I installed the Intel C++ compiler, but found out that most of the headers and libraries are absent. On Windows it is dependent on MSVC's header files and libraries I suppose. How can I use Intel's own C/C++ library? Thank you,
mecej4
Black Belt
161 Views
As far as I know, the Intel-supplied libraries are intended to be additions, not replacements, to the MS-supplied C libraries. The exception may be a small number of functions for which ICL supplies higher-performance versions.
SergeyKostrov
Valued Contributor II
161 Views
Hi Meriko, >>...On Windows it is dependent on MSVC's header files and libraries... Please use MS Depends to verify which CRT-libraries are used. I'd like to refer you to an Intel manual: Intel® 64 and IA-32 Architectures Software Developer's Manual Volume 1: Basic Architecture download.intel.com/products/processor/manual/253665.pdf in order to get more technical information regarding a 'long double' data type. My personal recommendation is 'Do Not Use' 'long double' type and 'Use' 'double' type instead. However, I'll take a look at your test-case. Best regards, Sergey
SergeyKostrov
Valued Contributor II
161 Views
>>... >>cout [left-arrow-left-arrow] sizeof(long double) [left-arrow-left-arrow] endl; >>... How did you get a value 16? It has to be 10 for Intel & Microsoft C++ compilers, and 12 for MinGW C++ compiler.
TimP
Black Belt
161 Views
Sergey, sizeof doesn't tell how many bits are actually used in the data type. It tells how many storage bytes are consumed. In a 64-bit OS, 80-bit long double normally is stored on 16-byte boundaries for improved performance. Of course, it still will not compete with performance of 32- or 64-bit SSE or AVX data types. 32-bit gcc normally uses 12-byte boundaries, so icc ia32 would do the same. If your preference for x87 code is specific to 32-bit mode, that's understandable, but you should still consider portability factors, or specify when your advice is specific to 32-bit "ia32" or "387" mode.
meriko
Beginner
161 Views
Is Intel Compiler stand alone compiler with its own CRT libraries? Can I install Intel C++ compiler on Windows without having MCVS or Visual C++? Thank you,
Bernard
Black Belt
161 Views
MSVCRT run-time library does not support a long double primitive type.The only support for this type is for compatibility reason.For example MSVCRT implementation of library printf will cast long double to double before printing to stdout its value.
Bernard
Black Belt
161 Views
meriko You cannot by-pass Windows Msvcrt.dll runtime libraries without the drastically changing Windows infrastructure(I mean runtime libraries).Every program compiled on Win platform is dynamicaly linked with CRT-libraries.You can change compiler linking behaviour by hooking at runtime calls to CRT-functions and providing your own implementation.
SergeyKostrov
Valued Contributor II
161 Views
>>...Can I install Intel C++ compiler on Windows without having MCVS or Visual C++? I think Yes, but I'll need MS linker and CRT import libraries ( to build binaries ), and MS CRT DLLs ( to execute binaries ) from a Platform SDK. In a case when VS is not installed an installer should display a warning message.
Reply