INFINITY on gcc 3.3

A

Amit

Hi,
I am trying to use INFINITY in a c++ code that I have written. I am
using gcc 3.3 on os X 10.3.9
The compiler gives a warning

warning: floating constant exceeds range of "float"

My code uses the following where this error is given:
double c = INFINITY;

I use the following to compile my code:

g++ -c -pg -O -Wno-deprecated -ansi -pedantic -DANSI_HEADERS
-D_G_HAVE_BOOL test.C -I.

How can I resolve this problem? I used this same code in an older
version of gcc(probably 3.1 on RH 9) and it worked fine there..

thanks,
--A.
 
?

=?ISO-8859-1?Q?Stefan_N=E4we?=

Amit said:
Hi,
I am trying to use INFINITY in a c++ code that I have written. I am
using gcc 3.3 on os X 10.3.9
The compiler gives a warning

warning: floating constant exceeds range of "float"

My code uses the following where this error is given:
double c = INFINITY;

I use the following to compile my code:

g++ -c -pg -O -Wno-deprecated -ansi -pedantic -DANSI_HEADERS
-D_G_HAVE_BOOL test.C -I.

How can I resolve this problem? I used this same code in an older
version of gcc(probably 3.1 on RH 9) and it worked fine there..

thanks,
--A.

Where does INFINITY come from and how is it defined ?

You could try this:

<code>

#include <limits>
....
double c = std::numeric_limits<double>::infinity();

</code>

Stefan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top