Valhalla Legends Forums Archive | C/C++ Programming | Short, Long and Int

AuthorMessageTime
j0k3r
Is there some sort of advantage to using int over short or long? It seems to me (right now) it just causes confusion.
March 26, 2004, 12:28 AM
iago
None should be used, you should use int32, uint32, int16, etc.
March 26, 2004, 12:48 AM
Adron
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.
March 26, 2004, 2:58 AM
j0k3r
But if you were writing the same file on 2 computers that are different, couldn't that cause some problems?
March 26, 2004, 12:46 PM
iago
It depends how you're using it.

"for(int i = 0; i < 100; i++)" - using whichever is most efficient would make more sense.
March 26, 2004, 2:11 PM
Skywing
[quote author=Adron link=board=30;threadid=5991;start=0#msg51718 date=1080269928]
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.
[/quote]
Note that CL defines int as 32-bit on x86-64 and IA-64.
March 27, 2004, 12:52 AM
Adron
[quote author=Skywing link=board=30;threadid=5991;start=0#msg51956 date=1080348747]
Note that CL defines int as 32-bit on x86-64 and IA-64.
[/quote]

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?
March 27, 2004, 12:26 PM
Skywing
[quote author=Adron link=board=30;threadid=5991;start=0#msg52037 date=1080390381]
[quote author=Skywing link=board=30;threadid=5991;start=0#msg51956 date=1080348747]
Note that CL defines int as 32-bit on x86-64 and IA-64.
[/quote]

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?
[/quote]
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.
March 27, 2004, 7:15 PM
Nath
[quote author=Skywing link=board=30;threadid=5991;start=0#msg51956 date=1080348747]
[quote author=Adron link=board=30;threadid=5991;start=0#msg51718 date=1080269928]
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.
[/quote]
Note that CL defines int as 32-bit on x86-64 and IA-64.
[/quote]

Lol?
April 10, 2004, 5:11 PM
Nath
[quote][/quote]
Note that CL defines int as 32-bit on x86-64 and IA-64.
[quote][/quote]

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

little bytes :P
April 10, 2004, 5:12 PM
Myndfyr
[quote author=Nath link=board=30;threadid=5991;start=0#msg54396 date=1081617157]
[quote][/quote]
Note that CL defines int as 32-bit on x86-64 and IA-64.
[quote][/quote]

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

little bytes :P
[/quote]

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.
April 13, 2004, 10:02 PM

Search