long long problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • wolverine

    #1

    long long problem

    Hi,
    I compiled the following code

    int main()
    {
    long long a = 0x7ff0000000000 000L;
    }


    I got error "test.cpp:3 : error: integer constant is too large for
    "long" type". But i think that a long long variable can hold upto
    (2^63-1) which is greater that 0x7ff0000000000 000. Then why is the
    error coming. The error comes only in g++ compiler and not in visual
    studio. Could any one help me in this ?


    Thanks in advance
    Kiran.

  • aiooua

    #2
    Re: long long problem

    int main()
    {
    long long a = 0x7ff0000000000 000L;
    >
    }
    >
    I got error "test.cpp:3 : error: integer constant is too large for
    "long" type".
    what you need is - long long a=0x7ff00000000 00000LL;
    see http://www-ccs.ucsd.edu/c/syntax.htm...ger%20constant for more.

    thanks,

    Comment

    • aiooua

      #3
      Re: long long problem

      On Apr 3, 12:57 pm, "aiooua" <aio...@gmail.c omwrote:
      int main()
      {
      long long a = 0x7ff0000000000 000L;
      >
      }
      >
      I got error "test.cpp:3 : error: integer constant is too large for
      "long" type".
      >
      what you need is - long long a=0x7ff00000000 00000LL;
      seehttp://www-ccs.ucsd.edu/c/syntax.html#int eger%20constant for more.
      and btw - "ISO C++ does not support `long long'".
      dont count on that "LL" suffix to work everywhere.

      thanks,

      Comment

      • wolverine

        #4
        Re: long long problem

        On Apr 3, 1:08 pm, "aiooua" <aio...@gmail.c omwrote:
        On Apr 3, 12:57 pm, "aiooua" <aio...@gmail.c omwrote:
        >
        int main()
        {
        long long a = 0x7ff0000000000 000L;
        >
        }
        >
        I got error "test.cpp:3 : error: integer constant is too large for
        "long" type".
        >
        what you need is - long long a=0x7ff00000000 00000LL;
        seehttp://www-ccs.ucsd.edu/c/syntax.html#int eger%20constant formore.
        >
        and btw - "ISO C++ does not support `long long'".
        dont count on that "LL" suffix to work everywhere.
        >
        thanks,
        Thanks a lot. That piece of information helped.

        Comment

        Working...