INFINITY on gcc 3.3

Discussion in 'C++' started by Amit, Aug 18, 2005.

  1. Amit

    Amit Guest

    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.
    Amit, Aug 18, 2005
    #1
    1. Advertising

  2. Amit wrote:
    > 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
    =?ISO-8859-1?Q?Stefan_N=E4we?=, Aug 18, 2005
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. a_Conan
    Replies:
    3
    Views:
    496
    a_Conan
    Sep 8, 2005
  2. Sidney Cadot

    integer division towards -infinity

    Sidney Cadot, Jul 10, 2003, in forum: C Programming
    Replies:
    3
    Views:
    607
    Glen Herrmannsfeldt
    Jul 11, 2003
  3. Anand Pillai

    Queues - Is Infinity all right?

    Anand Pillai, Oct 5, 2003, in forum: Python
    Replies:
    9
    Views:
    302
    Ype Kingma
    Oct 8, 2003
  4. Skybuck Flying

    Infinity + Infinity (or NegInfinity - NegInfinity)

    Skybuck Flying, Oct 8, 2011, in forum: C Programming
    Replies:
    40
    Views:
    1,678
    Tim Rentsch
    Jan 25, 2012
  5. Jon A. Lambert

    Infinity and -Infinity

    Jon A. Lambert, Nov 5, 2005, in forum: Ruby
    Replies:
    3
    Views:
    323
    Trans
    Nov 6, 2005
Loading...

Share This Page