long

The type long is a 64-bit, signed, two's-complement quantity. It should be used when calculations on whole numbers may exceed the range of int. Using longs, the range of values is –263 to (263–1). Numbers up in this range will be increasingly prevalent in computing, and 264 in particular is a number that really needs a name of its own. In 1993, I coined the term “Bubbabyte” to describe 264 bytes. Just as 210 bytes is a Kilobyte, and 220 is a Megabyte, so 264 bytes is a Bubbabyte. Using a long, you can count up to half a Bubbabyte less one.

example declaration:

long nationalDebt;

range of values: –9,223,372,036,854,775,808 to 9,223,372,036,854,775,807

literals: The general form of long literals is the same as int literals, but with an “L” or “l” on the end to indicate “long.” However, never use the lowercase letter “l” to indicate a “long” literal as it is too similar to the digit “1.” Always use the uppercase letter “L” instead. The three kinds of long literals are:

  • A decimal literal, e.g., 2047L or –10L

  • An octal literal, e.g., 0777777L

  • A hexadecimal literal, e.g., 0xA5L or OxABadBabbeL

All long literals are 64-bit quantities. A long literal must be cast to assign it to something with fewer bits, such as byte, short, int, or char.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.147.27.171