Integer (computer Science) - Common Integral Data Types

Common Integral Data Types

Bits Name Range (assuming two's complement for signed) Decimal Digits (approx.) Uses Implementations
C/C++ C# Pascal and Delphi Java SQL
4 nibble, semioctet Signed: From −8 to 7, from −(23) to 23 − 1 1 Binary-coded decimal, single decimal digit representation. n/a n/a n/a n/a
Unsigned: From 0 to 15 which equals 24 − 1 2
8 byte, octet Signed: From −128 to 127, from −(27) to 27 − 1 3 ASCII characters int8_t, char sbyte Shortint byte tinyint
Unsigned: From 0 to 255 which equals 28 − 1 3 uint8_t, char byte Byte n/a unsigned tinyint
16 halfword, word, short Signed: From −32,768 to 32,767, from −(215) to 215 − 1 5 UCS-2 characters int16_t, short, int short Smallint short smallint
Unsigned: From 0 to 65,535 which equals 216 − 1 5 uint16_t ushort Word char unsigned smallint
32 word, long, doubleword, longword, int Signed: From −2,147,483,648 to 2,147,483,647, from −(231) to 231 − 1 10 UTF-32 characters, True Color with alpha, FourCC, ActionScript int int32_t, int, long int LongInt; Integer int int
Unsigned: From 0 to 4,294,967,295 which equals 232 − 1 10 uint32_t uint LongWord; DWord; Cardinal n/a unsigned int
64 word, doubleword, longword, long long, quad, quadword, int64 Signed: From −9,223,372,036,854,775,808 to 9,223,372,036,854,775,807, from −(263) to 263 − 1 19 Very large numbers int64_t, long, long long long Int64 long bigint
Unsigned: From 0 to 18,446,744,073,709,551,615 which equals 264 − 1 20 uint64_t ulong UInt64; QWord n/a unsigned bigint
128 octaword, double quadword Signed: From −170,141,183,460,469,231,731,687,303,715,884,105,728 to 170,141,183,460,469,231,731,687,303,715,884,105,727, from −(2127) to 2127 − 1 39 Complex scientific calculations C: only available as non-standard compiler-specific extension n/a n/a n/a
Unsigned: From 0 to 340,282,366,920,938,463,463,374,607,431,768,211,455 which equals 2128 − 1 39
n n-bit integer
(general case)
Signed: (−(2n−1)) to (2n−1 − 1) ⌈(n − 1) log10 2⌉ Ada range -2**(n-1)..2**(n-1)-1
Unsigned: 0 to (2n−1) n log10 2⌉ Ada range 0..2**n-1, Ada mod 2**n
  1. ^ Not all SQL dialects have unsigned datatypes.
  2. The sizes of short, int, and long in C/C++ are dependent upon the implementation of the language; dependent on data model, even short can be anything from 16-bit to 64-bit. For some common platforms:
    • On older, 16-bit operating systems, int was 16-bit and long was 32-bit.
    • On 32-bit Linux, DOS, and Windows, int and long are 32-bits, while long long is 64-bits. This is also true for 64-bit processors running 32-bit programs.
    • On 64-bit Linux, int is 32-bits, while long and long long are 64-bits.
  3. The sizes of Delphi's Integer and Cardinal are not guaranteed, varying from platform to platform; usually defined as LongInt and LongWord respectively.
  4. ^ Java does not directly support arithmetic on char types. The results must be cast back into char from an int.

Different CPUs support different integral data types. Typically, hardware will support both signed and unsigned types but only a small, fixed set of widths.

The table above lists integral type widths that are supported in hardware by common processors. High level programming languages provide more possibilities. It is common to have a ‘double width’ integral type that has twice as many bits as the biggest hardware-supported type. Many languages also have bit-field types (a specified number of bits, usually constrained to be less than the maximum hardware-supported width) and range types (which can represent only the integers in a specified range).

Some languages, such as Lisp, Smalltalk, REXX and Haskell, support arbitrary precision integers (also known as infinite precision integers or bignums). Other languages which do not support this concept as a top-level construct may have libraries available to represent very large numbers using arrays of smaller variables, such as Java's BigInteger class or Perl's "bigint" package. These use as much of the computer’s memory as is necessary to store the numbers; however, a computer has only a finite amount of storage, so they too can only represent a finite subset of the mathematical integers. These schemes support very large numbers, for example one kilobyte of memory could be used to store numbers up to 2466 decimal digits long.

A Boolean or Flag type is a type which can represent only two values: 0 and 1, usually identified with false and true respectively. This type can be stored in memory using a single bit, but is often given a full byte for convenience of addressing and speed of access.

A four-bit quantity is known as a nibble (when eating, being smaller than a bite) or nybble (being a pun on the form of the word byte). One nibble corresponds to one digit in hexadecimal and holds one digit or a sign code in binary-coded decimal.

Read more about this topic:  Integer (computer Science)

Famous quotes containing the words common, integral, data and/or types:

    I want relations which are not purely personal, based on purely personal qualities; but relations based upon some unanimous accord in truth or belief, and a harmony of purpose, rather than of personality. I am weary of personality.... Let us be easy and impersonal, not forever fingering over our own souls, and the souls of our acquaintances, but trying to create a new life, a new common life, a new complete tree of life from the roots that are within us.
    —D.H. (David Herbert)

    Self-centeredness is a natural outgrowth of one of the toddler’s major concerns: What is me and what is mine...? This is why most toddlers are incapable of sharing ... to a toddler, what’s his is what he can get his hands on.... When something is taken away from him, he feels as though a piece of him—an integral piece—is being torn from him.
    Lawrence Balter (20th century)

    To write it, it took three months; to conceive it three minutes; to collect the data in it—all my life.
    F. Scott Fitzgerald (1896–1940)

    The American man is a very simple and cheap mechanism. The American woman I find a complicated and expensive one. Contrasts of feminine types are possible. I am not absolutely sure that there is more than one American man.
    Henry Brooks Adams (1838–1918)