• Welcome to Valhalla Legends Archive.
 

Short, Long and Int

Started by j0k3r, March 25, 2004, 06:28 PM

Previous topic - Next topic

j0k3r

Is there some sort of advantage to using int over short or long? It seems to me (right now) it just causes confusion.
QuoteAnyone attempting to generate random numbers by deterministic means is, of course, living in a state of sin
John Vo

iago

None should be used, you should use int32, uint32, int16, etc.
This'll make an interesting test for broken AV:
QuoteX5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*


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.

j0k3r

But if you were writing the same file on 2 computers that are different, couldn't that cause some problems?
QuoteAnyone attempting to generate random numbers by deterministic means is, of course, living in a state of sin
John Vo

iago

It depends how you're using it.

"for(int i = 0; i < 100; i++)" - using whichever is most efficient would make more sense.
This'll make an interesting test for broken AV:
QuoteX5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*


Skywing

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.

Adron

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?

Skywing

#7
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.

Nath

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?

Nath

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

MyndFyre

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.
QuoteEvery generation of humans believed it had all the answers it needed, except for a few mysteries they assumed would be solved at any moment. And they all believed their ancestors were simplistic and deluded. What are the odds that you are the first generation of humans who will understand reality?

After 3 years, it's on the horizon.  The new JinxBot, and BN#, the managed Battle.net Client library.

Quote from: chyea on January 16, 2009, 05:05 PM
You've just located global warming.