Abby Chau Yu Hoi
Abby Chau Yu Hoi

Reputation: 1398

Why is the 64bit integer extension of C++ called "long long"?

Unlike other types:"int","boolean","double", etc. And even custom classes, there are one word only. There is only one word for their type, however, only that integer is using two words; how and why can it be that special?

Upvotes: 1

Views: 615

Answers (5)

John Mashey
John Mashey

Reputation: 21

Actually, as I wrote in "The Long Road to 64-bits"

"Sometime around 1984, Amdahl UTS and Convex added long long for 64-bit integers, the former on a 32-bit architecture, the latter on a 64-bitter. UTS used this especially for long file pointers, one of the same motivations for long in PDP-11 Unix (1977). Algol 68 inspired long long in 1968, and it was also added to GNU C at some point. Many reviled this syntax, but at least it consumed no more reserved keywords."

I don't know offhand when GCC added long long, but since GCC 1.0 was released in 1987, these others were earlier.

Really, in practice this was decided de facto by the 1992 working grooup described in "The Long Road".

Upvotes: 2

NevilleDNZ
NevilleDNZ

Reputation: 1279

From: "The Long Road to 64 Bits" - by John R. Mashey | October 1, 2006 -Topic: System Evolution

"Algol 68 inspired long long in 1968, and it was also added to GNU C at some point."

Extract: Chronology: Multiple Interlocking Threads

  • 1964 IBM S/360: 32-bit, with 24-bit addressing (16 MB total) of real (core) memory.
  • 1968 Algol 68: includes long long. [long long for int, and also long long real, compl, bits and bytes]
  • 1970 DEC PDP-11/20: 16-bit, 16-bit addressing (64 KB total). IBM S/370 family: virtual memory, 24-bit addresses, but multiple user address spaces allowed.
  • ...
  • 1984 Motorola MC68020: 32-bit; 32-bit addressing.
  • 1984 C: Amdahl UTS (32-bit S/370) uses long long, especially for large file pointers.
  • 1984 C: Convex (64-bit vector mini-supercomputer) uses long long for 64-bit integers.
  • 1986 Intel: 80386, 32-bit, with support for 8086 mode.
  • ...
  • 1989 ANSI C (“C89”): effort had started in 1983, ANSI X3J11.
  • 1992 SGI: ships first 64-bit micro (MIPS R4000); still running 32-bit operating system. 64-bit C working group: discusses various models (LP64, ILP64, LLP64), with little agreement.
  • 1992 DEC: ships 64-bit Alpha systems, running 64-bit operating system; LP64.
  • 1994 SGI: ships IRIX 6 (64/32 operating system; ILP32LL + LP64) on Power Challenge; customers buy 4 GB+ memory, use it. DEC: ships 4 GB+ in DEC 7000 SMPs (may have been slightly earlier).
  • 1995 Sun UltraSPARC: 64/32-bit hardware, 32-bit-only operating system. HAL Computer’s SPARC64: uses ILP64 model for C.
  • 1995 Large file summit: codifies 64-bit interface to files >2 GB, even in 32-bit systems (ILP32LL+LP64).
  • 1994 Aspen group: supports LP64 model for C so that Unix vendors are consistent.
  • 1996 HP: announces PA-RISC 2.0, 64-bit.
  • ...

End extract.

Note: Standard Algol68↗ does not have long char for unicode/UTF16, nor long long char, but (conveniently) the size of a char is not required to be the same size as that of a byte. Sometimes - "traditionally" - a char was less then 8-bits, e.g. 6-bits (ASCII or GOST) or 7-bits (eg ASCII and now GSM_03.38)

Upvotes: 3

Pete Becker
Pete Becker

Reputation: 76458

The reason that the C++ and C standards adopted long long is that GCC had been using it for years, and, despite it's inherent ugliness, existing practice won out. As to why GCC chose that name, you'll have to ask them. <g>.

Upvotes: 1

Andreas Rossberg
Andreas Rossberg

Reputation: 36118

The naming scheme for C types ultimately seems to inherit from good old Algol, which allowed arbitrary numbers of "short" or "long" prefixes before types like int or real (it's name for floats). Of course, their interpretation was implementation dependent, and there was no guarantee that long long long int was actually any bigger than long int.

C inherited the prefixes (for ints at least, strangely enough they chose something more adhoc for floats), but at the time did not see the need for allowing to iterate them. And because C was pretty lax in many respects, it also allowed to drop the int itself in the case of long int.

With the advent of 64 bit machines, the assumption that only few sizes, and thus a single prefix in this scheme, are needed broke, and compilers started supporting long long. Part of the reason this scheme was rediscovered probably was that it did not require clobbering a new name or keyword. C99 then made this type official part of the standard, and C++ later inherited it.

Upvotes: 2

River Tam
River Tam

Reputation: 3216

long long differentiates itself from long, which is typically only 4 bytes (32 bits).

long is a modifier, which can be used on many primitive types to modify them.

Upvotes: 0

Related Questions