What to use for long long int?

This is a discussion on What to use for long long int? within the C Programming forums, part of the General Programming Boards category; I saw here that we can there is a data type "long long int". Can we use it on 32 ...

  1. #1
    Registered User
    Join Date
    Jul 2009
    Posts
    2

    What to use for long long int?

    I saw here that we can there is a data type "long long int". Can we use it on 32 bit machines?
    And as we use %d for int in scanf(),printf() functions, what to use for long long int?

    And also what is the range of long int on a 32 bit machine?
    Thank you.
    Last edited by macbook; 07-11-2009 at 09:10 AM.

  2. #2
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Posts
    23,027
    long long int is 64 bits.
    long int is long, thus usually 32 bits.
    %lld should be fine for printf, but you should really look up the format specifications instead of asking. It's easy.
    And yes, you can use long long on 32-bit machines.
    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.

  3. #3
    Registered User
    Join Date
    Jul 2009
    Posts
    2
    I am new to this thread, where to look for format specifications?
    And plz, the range of long int?? Can it hold numbers as big as 4 x 10^9?

  4. #4
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Posts
    23,027
    If long is 32 bits (it's not guaranteed to be), then it can hold up to 2^32 - 1, or half that if signed.
    Same goes for 64 bits: 2^64 - 1, or half if signed.
    Specifications? Use google!
    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
    Apr 2010
    Posts
    1

    assign and print 12 digit numeric datatype

    Hi,
    I am new this topic as well as to the forum. Can any one pls give me a sample program for AIX 32 bit machine
    1. assign 999999999999 value to appropreate data type
    2. print the above value.

  6. #6
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    Welcome, Vinu_pl.

    Try an unsigned long long int. If your compiler doesn't support long long, then try unsigned long int, and see if it works.

    Don't be afraid to try these things, Vinu. You have to be willing to explore to get to know programming. Get into it!

  7. #7
    Registered User
    Join Date
    Sep 2008
    Location
    Toronto, Canada
    Posts
    1,832
    999999999999 would need 40 bits. So the next data type that would be big enough is a 64-bit integer.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Debug Error Really Quick Question
    By GCNDoug in forum C Programming
    Replies: 1
    Last Post: 04-23-2007, 01:05 PM
  2. About aes
    By gumit in forum C Programming
    Replies: 13
    Last Post: 10-24-2006, 04:42 PM
  3. Converted from Dev-C++ 4 to Dev-C++ 5
    By Wraithan in forum C++ Programming
    Replies: 8
    Last Post: 12-03-2005, 07:45 AM
  4. Switch/case Problems (long code in post)
    By Wraithan in forum C++ Programming
    Replies: 2
    Last Post: 12-01-2005, 06:40 PM
  5. easy if you know how to use functions...
    By Unregistered in forum C Programming
    Replies: 7
    Last Post: 01-31-2002, 07:34 AM

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