#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2009
    Posts
    18
    Rep Power
    0

    Is there a reason not to use really large data types ?


    Hi,

    Is there any reason not to just use the 'long' data type for storing numbers instead of a smaller one like 'int' ?

    Do they take up more memory or something ?
  2. #2
  3. No Profile Picture
    Lost in code
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 2004
    Posts
    8,317
    Rep Power
    7170
    The answer to this question is fairly complex and depends greatly on what programming language you are using.

    Ints are usually <= 4 bytes, and while longs are usually >= 4 bytes. So, in some cases longs do use more memory than ints, and in some cases they use the same amount. I am fairly certain that longs never use less memory than ints.

    The matter is further complicated by the fact that many computer architectures have a minimum size limit on individual chunks of data. In many cases this limit is 4 bytes. For this reason, even if an int is defined as being only 2 bytes it might consume the same amount of space as a 4 byte long.
    PHP FAQ

    Originally Posted by Spad
    Ah USB, the only rectangular connector where you have to make 3 attempts before you get it the right way around
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2010
    Location
    London
    Posts
    96
    Rep Power
    0
    I think it has much thing to do with the memory.

IMN logo majestic logo threadwatch logo seochat tools logo