KIM COMPUTER


Integer Basics

An Integer is a number that can be written without a fractional component. The set of integers includes positive numbers, negative numbers, and zero. Integers are fundamental in mathematics and computer science, represented by $\mathbb{Z}$.


1. Definition and Classification

Integers are broadly classified into three types:

  1. Positive Integers: Also known as Natural Numbers, these are integers greater than zero: $1, 2, 3, \dots$
  2. Zero: The neutral integer, which is neither positive nor negative.
  3. Negative Integers: Integers less than zero: $-1, -2, -3, \dots$

$$ \mathbb{Z} = {\dots, -3, -2, -1, 0, 1, 2, 3, \dots} $$

[Image of Integer number line]


2. Integer Representation in Computers

Computers store all data using Binary (0s and 1s). The way integers are represented depends on their size and whether they are positive or negative.

① Storage Size

Integers are stored in a fixed number of bits (e.g., 8-bit, 16-bit, 32-bit, 64-bit), such as int or long in C. A larger bit size allows for a wider range of values.

② Sign Handling: Two's Complement

Computers use the Two's Complement system to represent negative integers and simplify subtraction operations into addition.

Example (8-bit): * Positive 5: $\mathbf{0}0000101$ * Negative -5: Two's complement of $00000101$ $\rightarrow \mathbf{1}1111011$


3. Applications of Integers