Integer (computer Science) Article Index for
Integer
 

Information About

Integer (computer Science)





VALUE AND REPRESENTATION


The ''value'' of a Datum with an integral type is the mathematical integer that it corresponds to. The ''representation'' of this datum is the way the value is stored in the computer’s memory. Integral types may be ''unsigned'' (capable of representing only non-negative integers) or ''signed'' (capable of representing negative integers as well).

The most common representation of a positive integer is a string of Bit s, using the Binary Numeral System . The order of the bits varies; see Endianness . The ''width'' or ''precision'' of an integral type is the number of bits in its representation. An integral type with ''n'' bits can encode 2''n'' numbers; for example an unsigned type typically represents the non-negative values 0 through 2''n''−1.

There are three different ways to represent negative numbers in a binary numeral system. The most common is Two’s Complement , which allows a signed integral type with ''n'' bits to represent numbers from −2(n−1) through 2(n−1)−1. Two’s complement arithmetic is convenient because there is a perfect One-to-one Correspondence between representations and values, and because Addition and Subtraction do not need to distinguish between signed and unsigned types. The other possibilities are sign-magnitude and ones' complement. See Signed Number Representations for details.

Another, rather different, representation for integers is Binary-coded Decimal , which is still commonly used in Mainframe financial applications and in databases.


COMMON INTEGRAL DATA TYPES


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 , REXX and Haskell , support ''arbitrary precision'' integers (also known as ''infinite precision integers'' or '' Bignum s''). 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 about 2466 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.


POINTERS


A Pointer is often, but not always, represented by an integer of specified width. This is often, but not always, the widest integer that the hardware supports directly. The value of this integer is the ''memory address'' of whatever the pointer points to.


BYTES AND OCTETS

See Also: Byte


The term ''byte'' initially meant ‘the least addressable unit of memory’. In the past, 5-, 6-, 7-, 8-, and 9-bit bytes have all been used. There have also been computers that could address individual bits (‘bit-addressed machine’), or that could only address 16- or 32-bit quantities (‘word-addressed machine’). The term ''byte'' was usually not used at all in connection with bit- and word-addressed machines.

The term ''octet'' always refers to an 8-bit quantity. It is mostly used in the field of Computer Network ing, where computers with different byte widths might have to communicate.

In modern usage ''byte'' almost invariably means eight bits, since all other sizes have fallen into disuse; ''byte'' has thus come to be synonymous with ''octet''.

Bytes are used as the Unit of Computer Storage of all kinds. One might speak of a 50-byte text string, a 100 KB (kilobyte) file, a 128 MB (megabyte) RAM module, or a 30 GB (gigabyte) Hard Disk . The prefixes used for byte measurements are usually written the same as the SI Prefix es used for other measurements, but they often have somewhat different values, powers of 1024 rather than 1000, as illustrated in the table below. See Binary Prefix for further discussion of this difference.


WORDS

See Also: Word (computer science)


The term ''word'' is used for a small group of bits which are handled simultaneously by processors of a particular Architecture . The size of a word is thus CPU-specific. Many different word sizes have been used, including 6-, 8-, 12-, 16-, 18-, 24-, 32-, 36-, 39-, 48-, 60-, and 64-bit. Since it is architectural, the size of a ''word'' is usually set by the first CPU in a family, rather than the characteristics of a later compatible CPU. The meanings of terms derived from ''word'', such as ''longword'', ''doubleword'', ''quadword'', and ''halfword'', also vary with the CPU and OS.

As Of 2004 , 32-bit word sizes are most common among general-purpose computers, with 64-bit machines used mostly for large installations. Embedded Processors with 8- and 16-bit word size are still common. The 36-bit Word Length was common in the early days of computers, but word sizes that are not a multiple of 8 have vanished along with non-8-bit bytes.