A computer does not understand numbers, letters, or symbols in the same form that humans see them. At the hardware level, information is stored and processed as patterns of binary digits, commonly represented by 0 and 1. Data representation is the set of rules used to convert different kinds of information into these binary patterns and interpret them correctly when they are used.
A simple unsigned binary number is sufficient when a program only needs positive whole numbers. Real computer programs, however, work with much more than that. They may need negative integers, decimal values, characters, text, and other forms of information. Each type of data therefore needs an appropriate representation method.
This topic is important in Computer Organization because representation affects how much storage is required, how arithmetic operations are performed, and how hardware interprets a particular sequence of bits. In this chapter, we will focus on integer representation, character representation, and floating-point representation.
Data representation refers to the method used by a computer system to encode information into a form that digital hardware can store and process. Since digital circuits operate with two logical states, information is ultimately represented through combinations of binary digits.
The same binary pattern can have different meanings depending on the representation being used. For example, the bit pattern 11111111 can represent the unsigned decimal value 255, while under an 8-bit two's complement interpretation it represents -1. The bits themselves have not changed; only the interpretation has changed.
This distinction is one of the most important ideas in data representation: bits do not carry meaning by themselves. The representation rule gives those bits their meaning.
Different types of information require different representation techniques. Some important categories are:
The representation chosen determines how the available bits are divided and how the resulting binary pattern should be interpreted.
An unsigned integer representation uses all available bits to represent the magnitude of a non-negative number. There is no separate sign bit because negative values are not included in the range.
For an n-bit unsigned number, the possible values range from:
0 to 2n - 1
Using 8 bits:
00000000 = 0
00000001 = 1
00000010 = 2
...
11111111 = 255
Therefore:
Maximum value = 2^8 - 1
= 255
Unsigned representation is useful for quantities that cannot logically be negative, such as some counters, memory sizes, and address-related values.
Many calculations require negative values. A temperature may be below zero, a financial calculation may produce a negative balance, and a mathematical operation such as 7 - 12 produces -5. Ordinary unsigned binary cannot represent these negative results.
To solve this problem, several signed-number representations have been developed. The three classical methods commonly studied in Computer Organization are:
These methods use the same basic binary digits but interpret them differently.
In sign-magnitude representation, the most significant bit is used as the sign bit. A sign bit of 0 indicates a positive number, while a sign bit of 1 indicates a negative number. The remaining bits represent the magnitude of the number.
13 in binary: 00001101 For +13: Sign bit = 0 Magnitude = 0001101 Representation: 00001101 For -13: Sign bit = 1 Magnitude = 0001101 Representation: 10001101
The method is easy to understand because the sign and magnitude are kept separate. However, arithmetic hardware becomes more complicated because the sign has to be considered separately during calculations.
Another disadvantage is that sign-magnitude has two representations for zero:
00000000 = +0 10000000 = -0
The existence of two zeros is undesirable for general-purpose integer arithmetic.
In 1's complement representation, a positive number is represented using ordinary binary. To obtain the negative representation, every bit of the positive value is inverted.
In other words:
0 becomes 1 and 1 becomes 0
+13: 00001101 Invert every bit: 11110010 Therefore: -13 = 11110010
The method is straightforward, but it still has two representations of zero:
00000000 = +0 11111111 = -0
Another complication is that binary addition using 1's complement may require an end-around carry, which makes the arithmetic procedure less convenient than two's complement arithmetic.
Two's complement is the most important signed-integer representation for modern general-purpose computer systems. A negative value is obtained by first inverting all bits of the positive value and then adding 1.
Step 1: Write +13 00001101 Step 2: Find 1's complement 11110010 Step 3: Add 1 11110010 + 1 --------- 11110011 Therefore: -13 = 11110011
Two's complement has an important advantage: it has only one representation of zero. It also allows addition and subtraction to be implemented using closely related binary arithmetic operations.
For an n-bit two's complement representation, the range is:
-2n-1 to 2n-1 - 1
Minimum: -2^7 = -128 Maximum: 2^7 - 1 = 127 Therefore, an 8-bit signed two's complement number ranges from: -128 to +127
One of the major reasons two's complement is useful is that subtraction can be performed through addition. Instead of building a completely separate arithmetic process for subtraction, the computer can add the two's complement of the number being subtracted.
18: 00010010 7: 00000111 Two's complement of 7: 00000111 11111000 ← invert 11111001 ← add 1 Now add: 00010010 + 11111001 ----------- 1 00001011 Ignore the carry outside 8 bits: 00001011 00001011 = 11 Therefore: 18 - 7 = 11
This ability to use binary addition hardware for signed subtraction greatly simplifies the design of arithmetic units.
| Property | Sign-Magnitude | 1's Complement | 2's Complement |
|---|---|---|---|
| Negative number formation | Change sign bit | Invert all bits | Invert all bits and add 1 |
| Number of zero representations | Two | Two | One |
| Arithmetic implementation | More complicated | Requires end-around carry | Convenient for binary arithmetic |
| Modern general-purpose use | Mostly historical/limited | Mostly historical/limited | Widely used for signed integers |
A computer has a fixed number of bits available for an integer. If the result of an operation requires a value outside the representable range, overflow can occur.
For example, an 8-bit two's complement number can represent values only from -128 to +127. Therefore, adding two positive values and obtaining a mathematical result greater than 127 cannot be represented correctly in that 8-bit signed format.
100 + 50 = 150 But the maximum 8-bit two's complement value is: +127 Therefore: 150 cannot be represented as an 8-bit signed integer. This condition is called overflow.
Overflow is different from simply having a carry out of the most significant bit. In signed arithmetic, the interpretation of the result and the signs of the operands must also be considered.
Numbers are not the only information that computers need to store. Programs also work with letters, digits, punctuation marks, and symbols. To store text, a character must be associated with a numerical code that can be represented in binary.
Character encoding defines this relationship between characters and numerical values.
ASCII stands for American Standard Code for Information Interchange. Standard ASCII uses 7 bits and defines codes for 128 characters, including English letters, decimal digits, punctuation marks, and control characters.
Character: A Decimal ASCII value: 65 Binary: 1000001 Character: a Decimal ASCII value: 97 Binary: 1100001
The uppercase letter A and lowercase letter a therefore have different numerical codes.
ASCII is useful for understanding the basic idea of character encoding, but standard ASCII cannot represent the large number of characters required by languages and writing systems around the world.
Modern software commonly relies on Unicode rather than limiting text to the original ASCII character set. Unicode provides a much larger collection of code points so that characters from many writing systems can be represented.
Unicode and character encoding formats such as UTF-8 are important when storing or transmitting multilingual text. UTF-8 is also backward-compatible with the original ASCII byte values for the standard ASCII character set.
This distinction is useful: Unicode defines a large character repertoire, while an encoding such as UTF-8 specifies how those characters are represented as bytes.
Integers cannot represent values such as 3.14, 0.125, or 0.000004 using ordinary integer representation. Computers therefore use floating-point formats to represent numbers that contain fractional values and numbers with very large or very small magnitudes.
The basic idea is similar to scientific notation. In decimal notation, a number can be written in a form such as:
6.25 × 10^3
A binary floating-point representation uses a similar concept, but the base is 2.
12.5 in decimal 12.5 = 1100.1 in binary Normalize: 1100.1 = 1.1001 × 2^3
A floating-point format stores information corresponding to the sign, the significant portion of the number, and its exponent.
IEEE 754 is a widely used standard for representing floating-point numbers. Common formats include single precision and double precision.
| Field | Number of Bits | Purpose |
|---|---|---|
| Sign | 1 | Indicates positive or negative sign |
| Exponent | 8 | Represents the scale of the value |
| Fraction | 23 | Stores the significant fraction bits |
The total is 32 bits. IEEE 754 uses a biased exponent rather than storing the exponent directly as an ordinary signed integer. The representation also defines special values such as positive and negative infinity, NaN (Not a Number), and signed zero.
Not every decimal fraction has an exact finite representation in binary. This is similar to how the fraction 1/3 cannot be represented exactly by a finite number of decimal digits.
For example, the decimal value 0.1 has a repeating representation when expressed in binary. A finite floating-point format therefore stores the closest representable value rather than an infinitely precise version of the decimal number.
As a result, calculations involving floating-point values can sometimes produce results that differ slightly from the exact mathematical result. This is an important consideration in numerical computing and software development.
A useful way to understand data representation is to examine one fixed bit pattern under different interpretation rules.
Unsigned 8-bit interpretation: 11111111 = 255 1's complement interpretation: 11111111 = -0 2's complement interpretation: 11111111 = -1
The physical bits remain exactly the same. What changes is the rule used to interpret them. This is why computer architecture must define data formats clearly.
Data representation directly influences hardware design. Arithmetic circuits need to know whether their inputs are signed or unsigned, comparison circuits must interpret the bit patterns correctly, and processors need defined formats for instructions and operands.
For example, an arithmetic logic unit can perform binary addition on bit patterns, but the interpretation of the resulting pattern depends on the data type and operation being performed. The processor's instruction set and programming environment provide the rules that determine how those bits should be interpreted.
This connection between binary representation and hardware behavior is one reason data representation is a fundamental topic in Computer Organization.
Consider a simple student-record application. The application may need to store a student's age, examination score, name, and average percentage. These values do not necessarily require the same representation.
| Information | Possible Representation | Reason |
|---|---|---|
| Age | Integer | Age is normally represented as a whole number. |
| Exam score | Unsigned integer | A score may be restricted to non-negative values. |
| Student name | Character encoding | A name consists of characters rather than a single numerical quantity. |
| Average percentage | Floating point | The value may contain a fractional part. |
The example demonstrates why computers need multiple representation methods instead of treating every piece of information as an ordinary unsigned integer.
| Data Type | Common Representation | Main Purpose |
|---|---|---|
| Positive integer | Unsigned binary | Represent non-negative whole numbers |
| Signed integer | Two's complement | Represent positive and negative whole numbers |
| Character | ASCII / Unicode encoding | Represent textual symbols |
| Fractional number | IEEE 754 floating point | Represent fractional values and large numerical ranges |
Data representation is the method used to encode information into binary patterns so that computer hardware can store, process, and interpret it.
Signed representation is required when a computer needs to represent both positive and negative integer values.
Sign-magnitude representation uses the most significant bit as a sign indicator and the remaining bits to represent the magnitude.
The positive binary representation is inverted bit by bit to obtain the 1's complement representation of the negative value.
First invert all bits of the positive binary number and then add 1 to the resulting binary value.
It provides a single representation of zero and makes signed addition and subtraction convenient for digital arithmetic hardware.
ASCII is a character encoding standard that assigns numerical codes to characters such as letters, digits, punctuation marks, and control characters.
ASCII defines a relatively small set of character codes, while Unicode provides a much larger character repertoire suitable for text from many writing systems.
Floating-point representation stores numerical values using a sign, exponent, and significant portion, allowing computers to represent fractional values and a wide range of magnitudes.
Overflow occurs when an arithmetic result is outside the range that can be represented using the available number of bits.
Data representation is the bridge between information that humans understand and the binary operations performed by digital hardware. A computer does not store a negative integer, a letter, or a decimal fraction in its familiar human-readable form. Instead, each type of information follows a defined encoding or representation rule.
For signed integers, sign-magnitude and 1's complement are important historical concepts, while two's complement provides the representation most commonly associated with signed integer arithmetic in modern computer systems. For text, character encoding standards such as ASCII and Unicode establish the relationship between characters and numerical codes. Floating-point formats extend binary representation to fractional values and very large or very small numbers.
Once these representation methods are understood, many other Computer Organization topics become easier to follow because operations performed by the CPU, ALU, registers, and memory all ultimately operate on these encoded bit patterns.