Numeric data are represented in the computer using straight binary coding, which encodes an entire number as a whole. Straight binary coding requires that numbers be stored in computer memories as a fixed number of bits.
A group of bits so treated as a unit is called a word, and the number of bits is called the length of the word. Let’s know the process of numeric data representation on the computer.
Numeric data representation
Integers or fixed-point numbers have no decimal points. An integer 1 is represented in the memory of the computer by its binary form if 1 is positive, and by its 2’s complement if I am negative.
Example: Storing 1101001112 that is 42310, and – 42310 in 32-bit memory location
For simplicity, we assume that the word length is 32. The computer stores 423 which is 1101001112 in a 32-bit memory location by introducing 0s at the beginning of the binary form. Thus:
The computer stores 423 in a memory location in 2’s complement form for 423, that is
In the first display the dots represent omitted 0s; in the second omitted 1’s.
The computer can tell whether an integer 1 in memory is positive or negative by looking at the leftmost bit. If the leftmost bit is 0, then 1 is positive; if the leftmost bit is 1, then 1 is negative.
Accordingly, the largest (positive) integer that can be stored in a 32-bit memory location is
Or 2³¹ -1, which is approximately 2 billion. Similarly, the smallest (that is negative) integer that can be stored in a 32-bit memory location is -2³¹ -1, or approximately -2 billion.
You may like also: