FazBrowse Wikipedia Viewer | Main Page |
Search Wikipedia:
|
Viewing: https://en.wikipedia.org/wiki/Unsigned_integer

Integer (computer science)

In computer science, an integer is a datum of integral data type, a data type that represents some range of mathematical integers. Integral data types may be of different sizes and may or may not be allowed to contain negative values. Integers are commonly represented in a computer as a group of binary digits (bits). The size of the grouping varies so the set of integer sizes available varies between different types of computers. Computer hardware nearly always provides a way to represent a processor register or memory address as an integer.

"}},"i":0}}]}'>−2 through (''n''−1)</sup> − 1"}},"i":0}}]}'>2 − 1. Two's complement arithmetic is convenient because there is a perfect one-to-one correspondence between representations and values (in particular, no separate +0 and −0), and because addition, subtraction and multiplication do not need to distinguish between signed and unsigned types. Other possibilities include offset binary, sign-magnitude, and ones' complement.

Some computer languages define integer sizes in a machine-independent way; others have varying definitions depending on the underlying processor word size. Not all language implementations define variables of all integer sizes, and defined sizes may not even be distinct in a particular implementation. An integer in one programming language may be a different size in a different language, on a different processor, or in an execution context of different bitness; see § Words.

Some older computer architectures used decimal representations of integers, stored in binary-coded decimal (BCD) or other format. These values generally require data sizes of four bits per decimal digit (sometimes called a nibble), usually with additional bits for a sign. Many modern CPUs provide limited support for decimal integers as an extended datatype, providing instructions for converting such values to and from binary values. Depending on the architecture, decimal integers may have fixed sizes (e.g., seven decimal digits plus a sign fit into a 32-bit word), or may be variable-length (up to some maximum digit size), typically occupying two digits per byte (octet).

Common integral data types

edit
Bits Name Range (assuming two's complement for signed) Decimal digits Uses Implementations
C/C++ C# Pascal and Delphi Java SQL FORTRAN D Rust
4 nibble, semioctet Signed: From −8 to 7, from −(2) to 3</sup> − 1"}},"i":0}}]}'>2 − 1 2 − 1 2.11 ASCII characters, code units in the UTF-8 character encoding int8_t, signed char sbyte, System.SByte Shortint byte, java.lang.Byte tinyint INTEGER byte i8
Unsigned: From 0 to 255, which equals 8</sup> − 1"}},"i":0}}]}'>2 − 1 —4.52 UCS-2 characters, code units in the UTF-16 character encoding int16_t, short, int short, System.Int16 Smallint short, java.lang.Short smallint INTEGER short i16
Unsigned: From 0 to 65,535, which equals 16</sup> − 1"}},"i":0}}]}'>2 − 1 N/a ushort u16
32 word, long, doubleword, longword, int, i32, u32 Signed: From −2,147,483,648 to 2,147,483,647, from −(2) to 31</sup> − 1"}},"i":0}}]}'>2 − 1 9.63 uint32_t, unsigned, unsigned int, unsigned long uint, System.UInt32 LongWord; DWord; Cardinal —9,223,372,036,854,775,807</span>"}]]}'>2 − 1 18,446,744,073,709,551,615</span>"}]]}'>2 − 1 N/a unsigned bigint −170,141,183,460,469,231,731,687,303,715,884,105,728</span>"}]]}'>−(2) to 127</sup> − 1}}"},"2":{"wt":"170,141,183,460,469,231,731,687,303,715,884,105,727"}},"i":0}}]}'/>170,141,183,460,469,231,731,687,303,715,884,105,727</span>"}]]}'>2 − 1 340,282,366,920,938,463,463,374,607,431,768,211,455</span>"}]]}'>2 − 1 n − 1) log10 2 C23: _BitInt(n), signed _BitInt(n) Ada: range 0..2**n-1,
View original on Wikipedia | Back | FazBrowse Home