Thread: whats the difference between int and long?

  1. #1
    ima n00b, ok? orion-'s Avatar
    Join Date
    Aug 2005
    alberta, canada

    whats the difference between int and long?

    the value range between int and long are both the same (-2147483648 to 2147483647) and they are both 4 bytes big! whats the difference and when do i know which variable type to use between the two when it comes to making my own app's?

  2. #2
    Sanity is for the weak! beene's Avatar
    Join Date
    Jul 2006
    A long integer has to be bigger than or equal to an int, so, if you want to set aside more memory for a variable, i would use long.
    Last edited by beene; 01-02-2007 at 09:01 AM.

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    The edge of the known universe
    > the value range between int and long are both the same
    On your machine, with your current compiler, for today.

    The standard specifies minimum ranges for data types. Use that to guide what you should choose.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  4. #4
    Registered User
    Join Date
    May 2003
    An int is defined as at least 16 bits long. It may be longer -- typically if you use a 16 bit compiler, int is 16 bits, 32 bit compiler = 32 bits, 64 bit compiler = 64 bits, but I do not believe that this is guaranteed. Still, on every compiler I've seen, sizeof(int) == sizeof(void *).

    A long is defined as at least 32 bits long, again it may be longer.
    You ever try a pink golf ball, Wally? Why, the wind shear on a pink ball alone can take the head clean off a 90 pound midget at 300 yards.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 48
    Last Post: 09-26-2008, 03:45 AM
  2. Code review
    By Elysia in forum C++ Programming
    Replies: 71
    Last Post: 05-13-2008, 09:42 PM
  3. Half-life SDK, where are the constants?
    By bennyandthejets in forum Game Programming
    Replies: 29
    Last Post: 08-25-2003, 11:58 AM
  4. How do you search & sort an array?
    By sketchit in forum C Programming
    Replies: 30
    Last Post: 11-03-2001, 05:26 PM
  5. A Simple (?) Problem
    By Unregistered in forum C++ Programming
    Replies: 8
    Last Post: 10-12-2001, 04:28 AM