Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.
7953 Discussions

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

drMikeT
New Contributor I
339 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
Honored Contributor III
339 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.
0 Kudos
drMikeT
New Contributor I
339 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

0 Kudos
Reply