Community
cancel
Showing results for 
Search instead for 
Did you mean: 
drMikeT
New Contributor I
63 Views

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

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
63 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
63 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