LeftHit.com

Sunday, November 18, 2007

Integer (computer science)
In computer science, the term integer is used to refer to any data type which can represent some subset of the mathematical integers. These are also known as integral data types.

Value and representation
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 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 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.

Integer (computer science) Common integral data types
Note: C++ has no compiler-independent integer types with fixed bit widths. C has them only since C99, in the form (u)int(n)_t. It does specify the minimum widths for char, short, int, long, and long long (as shown in the table above). It also specifies that each of those types is no larger than the following, and that char is exactly one byte (eight bits in vitually all modern computers; the exact value is defined as CHAR_BIT in <limits.h>, also for older machines with wider bytes).

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

No comments: