Where did the use of long variables in C come from?

One thing about C that I have always found intriguing is the data type specifiers. Take for example the simple int. Using the appropriate adjectives, this could be turned into any number of large integers:

short int
int 
long int
long long int

The frustrating thing has always been that the actual size of these types is system dependent. Where did these things come from? The answer in short is Algol 68. The language specification allowed primitive modes which included long int, long long int, but also short int, and short short int. A similar scenario with reals. The benefit was however that their length was better mandated, there wasn’t a scenario (like in C), where int and long or long and long long ended up being the same length.

short short int     - 8 bits
short int           - 16 bits
int                 - 32 bits
long int            - 64 bits
long long int       - 96 bits
long long long int  - 128 bits

Yes, you see it, it’s not a typo, long long long. At this stage you wonder why they didn’t come up with better adjectives, maybe very long int? I imagine, in most cases, compiler implementations used long long int as 128 bits and skipped the whole 96 bit thing. Of course C, in its mantra to condense code, did away with the suffix int, allowing simply long, or long long.

Maybe the crazier thing in C? The type-specifiers may occur in any order and can be intermixed with the other declaration specifiers. Therefore, all of the following are valid and equivalent.

long long 
long long int 
long int long 
int long long

Maybe the use of  long long long came from the Beatles album “The Beatles“, released in 1968. Algol68? Coincidence? I think not!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s