Valhalla Legends Archive

Programming => General Programming => C/C++ Programming => Topic started by: j0k3r on March 25, 2004, 06:28 PM

Title: Short, Long and Int
Post by: j0k3r on March 25, 2004, 06:28 PM
Is there some sort of advantage to using int over short or long? It seems to me (right now) it just causes confusion.
Title: Re:Short, Long and Int
Post by: iago on March 25, 2004, 06:48 PM
None should be used, you should use int32, uint32, int16, etc.
Title: Re:Short, Long and Int
Post by: Adron on March 25, 2004, 08:58 PM
You should use int when you want an integer. The compiler will give you the size that is most efficient to use on your current architecture.
Title: Re:Short, Long and Int
Post by: j0k3r on March 26, 2004, 06:46 AM
But if you were writing the same file on 2 computers that are different, couldn't that cause some problems?
Title: Re:Short, Long and Int
Post by: iago on March 26, 2004, 08:11 AM
It depends how you're using it.

"for(int i = 0; i < 100; i++)" - using whichever is most efficient would make more sense.
Title: Re:Short, Long and Int
Post by: Skywing on March 26, 2004, 06:52 PM
Quote from: Adron on March 25, 2004, 08:58 PM
You should use int when you want an integer. The compiler will give you the size that is most efficient to use on your current architecture.
Note that CL defines int as 32-bit on x86-64 and IA-64.
Title: Re:Short, Long and Int
Post by: Adron on March 27, 2004, 06:26 AM
Quote from: Skywing on March 26, 2004, 06:52 PM
Note that CL defines int as 32-bit on x86-64 and IA-64.

That's a strange thing. Int grew from 16-bit to 32-bit, but it's not growing to 64-bit on the intel architectures, only on real 64-bit machines?
Title: Re:Short, Long and Int
Post by: Skywing on March 27, 2004, 01:15 PM
Quote from: Adron on March 27, 2004, 06:26 AM
Quote from: Skywing on March 26, 2004, 06:52 PM
Note that CL defines int as 32-bit on x86-64 and IA-64.

That's a strange thing. Int grew from 16-bit to 32-bit, but it's not growing to 64-bit on the intel architectures, only on real 64-bit machines?
Microsoft decided against it for their compiler because apparently too many programs used types like int in files and such that would break compatibility.  I think you are supposed to use __int64 for 64-bit ints.
Title: Re:Short, Long and Int
Post by: Nath on April 10, 2004, 12:11 PM
Quote from: Skywing on March 26, 2004, 06:52 PM
Quote from: Adron on March 25, 2004, 08:58 PM
You should use int when you want an integer. The compiler will give you the size that is most efficient to use on your current architecture.
Note that CL defines int as 32-bit on x86-64 and IA-64.

Lol?
Title: Re:Short, Long and Int
Post by: Nath on April 10, 2004, 12:12 PM
Quote
Note that CL defines int as 32-bit on x86-64 and IA-64.
Quote

I'm a newbie -  std::cout << sizeof(int) << " bytes.\n";
std::cout << sizeof(long) << " bytes.\n";

little bytes  :P
Title: Re:Short, Long and Int
Post by: MyndFyre on April 13, 2004, 05:02 PM
Quote from: Nath on April 10, 2004, 12:12 PM
Quote
Note that CL defines int as 32-bit on x86-64 and IA-64.
Quote

I'm a newbie -  std::cout << sizeof(int) << " bytes.\n";
std::cout << sizeof(long) << " bytes.\n";

little bytes  :P

yes indeed you are a newbie -- you made two quotes without them saying anything...

Also, to avoid being annoying (not saying that you are, but doing it a jillion times makes it annoying), try and use the "Modify" feature rather than posting several times in a row.

Also, use the [ code ] [ /code ] tags to ensure proper formatting.