Intel® C++ Compiler
Support and discussions for creating C++ code that runs on platforms based on Intel® processors.
Announcements
This community is designed for sharing of public information. Please do not share Intel or third-party confidential information here.
7683 Discussions

Simple Q for INFINITY and other numerical constants in C/C++/Fortran code

drMikeT
New Contributor I
143 Views
I was wondering which header file includes a well defined constatnt for the numberical value + or- INFINITY for single or double precission FP quantities.

Some code is checking for preprocessor contstat "INFINITY" and if unddefined it "sets" it as follows :

#ifdef INFINITY
const double inf = INFINITY;
#else
const double inf = 1.0 / 0.0;
#endif

However, when I compile with icc I get:

harminv-main.c(126): error: floating-point operation result is out of range
const double inf = 1.0 / 0.0;
^

Where are these numerical quantities defined or how can I go about properly producing them programmatically with Intel compilers?

thanks ....

Michael
0 Kudos
2 Replies
TimP
Black Belt
143 Views
For Intel Windows C, INFINITY is defined in (which excludes use of Microsoft . Presumably, it would be defined in linux under -std=c99. As the discussions you have quoted indicate, INFINITY typically is a macro expression which isn't accepted as a compile-time constant.
drMikeT
New Contributor I
143 Views
Quoting TimP (Intel)
For Intel Windows C, INFINITY is defined in (which excludes use of Microsoft . Presumably, it would be defined in linux under -std=c99. As the discussions you have quoted indicate, INFINITY typically is a macro expression which isn't accepted as a compile-time constant.

Thanks Tim,

I couldn't see the '-std=c99' option in man page of icc. I tried and worked though.

thanks for the reply

Michael

Reply