Like Tree1Likes
  • 1 Post By GReaper

Long long type

This is a discussion on Long long type within the C++ Programming forums, part of the General Programming Boards category; I'm using Code::Block. I have this line of code: Code: define maxC 9000000000; //9.10^10 int main(){ long long min=maxC; } ...

  1. #1
    hqt
    hqt is offline
    Registered User
    Join Date
    Aug 2011
    Posts
    115

    Question Long long type

    I'm using Code::Block. I have this line of code:
    Code:
    define maxC 9000000000; //9.10^10
    int main(){
         long long min=maxC;
    }
    I think 9.10^10 doesn't exceed long long type. But, I don't know, when I'm compile this problem, there's a warning:
    <warning: integer constant is too large for 'long' type>
    Because, long type is just about 4.10^10 for unsign and 2.10^10 for sign integer. So, I cannot use it.

    So, how can I use long long type, and no above warning, please help me, please. (I think, they warning, mean sometimes, they will go wrong !!!)

    thanks

  2. #2
    Registered User
    Join Date
    May 2010
    Posts
    2,919
    First you should not have the semicolon at the end of your define. Second what compiler are you using?
    I think 9.10^10 doesn't exceed long long type. But, I don't know, when I'm compile this problem, there's a warning:
    If you need to know the size of the variables a type can hold on your system you should look at the functions in the limits include file:
    Code:
    #include <iostream>
    #include <limits>
    
    int main(){
       std::cout << "Maximum value for long:      " << std::numeric_limits<long>::max() << std::endl;
       std::cout << "Maximum value for long long: " << std::numeric_limits<long long>::max() << std::endl;
    }

    Jim
    Last edited by jimblumberg; 09-22-2011 at 11:27 PM.

  3. #3
    Programming Wraith GReaper's Avatar
    Join Date
    Apr 2009
    Location
    Greece
    Posts
    1,625
    Put a LL for long long suffix at the integer.
    9000000000LL
    iMalc likes this.
    Devoted my life to programming...

  4. #4
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Posts
    23,031
    >>define maxC 9000000000; //9.10^10
    const long long MaxC = 9000000000LL;
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  5. #5
    Registered User
    Join Date
    Aug 2010
    Location
    Poland
    Posts
    682
    Code:
    static const long long MaxC = 9000000000LL;
    EDIT:
    It's ok, I just read that static is not necessary...
    Last edited by kmdv; 09-23-2011 at 05:55 PM.
    I never put signature, but I decided to make an exception.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 1
    Last Post: 04-23-2011, 09:40 PM
  2. Replies: 1
    Last Post: 10-11-2010, 02:53 AM
  3. Conver long to 8 byte array and back to long
    By plopes in forum C Programming
    Replies: 3
    Last Post: 04-01-2009, 01:39 AM
  4. STLport with MingW - Long Long error on project build
    By Mario F. in forum C++ Programming
    Replies: 2
    Last Post: 08-21-2006, 09:55 AM
  5. Is long long int a valid Data Type
    By shiv_tech_quest in forum C Programming
    Replies: 2
    Last Post: 11-12-2003, 08:59 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21