ЁЯФм
ЁЯзм
ЁЯФн
ЁЯкР
ЁЯзк
тЖР Back to Dashboard
Font Size:

1. Introduction

Computers are digital machines that store and process all information using only two symbols: 0 and 1. Each such symbol is called a binary digit or a bit. Every number, character, image, sound and video that a computer handles is ultimately reduced to a sequence of bits. This chapter explains how numbers are represented in binary form, how different number systems are related, how negative numbers and fractional numbers are stored, and how text characters are encoded using standard codes. Understanding data representation is essential because it reveals how a computer actually interprets the information given to it by a programmer.

There are four main number systems used in computing: decimal (base 10), binary (base 2), octal (base 8) and hexadecimal (base 16). Each system has a base or radix that tells how many distinct symbols it uses. Decimal uses the digits 0 to 9, binary uses 0 and 1, octal uses 0 to 7, and hexadecimal uses 0 to 9 followed by A to F (representing values 10 to 15). A computer works internally in binary because digital electronic circuits have only two stable states, corresponding to a high voltage and a low voltage.

In addition to positional number systems, the chapter covers the representation of negative numbers using one's and two's complement, and the storage of real numbers using the IEEE floating-point format. It also introduces character encoding standards: ASCII, ISCII and Unicode, which allow text from many languages to be represented in a machine-readable form. A solid grip on these ideas is required for later chapters on Boolean logic and computer arithmetic.

2. Number Systems and Their Bases

A number system defines a set of symbols and rules for representing numbers. In a positional number system, the value of a digit depends on its position. The position of a digit multiplies its value by a power of the base.

2.1 Decimal Number System (Base 10)

The decimal system uses ten digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9. Each digit's value depends on its position. For example, the number 2456 means: (2 x 10^3) + (4 x 10^2) + (5 x 10^1) + (6 x 10^0) = 2000 + 400 + 50 + 6 = 2456.

2.2 Binary Number System (Base 2)

The binary system uses only two digits, 0 and 1. This is the natural language of digital computers. For example, the binary number 10110 means: (1 x 2^4) + (0 x 2^3) + (1 x 2^2) + (1 x 2^1) + (0 x 2^0) = 16 + 0 + 4 + 2 + 0 = 22 in decimal.

2.3 Octal Number System (Base 8)

The octal system uses eight digits: 0 to 7. It is convenient because 8 = 2^3, so each octal digit corresponds to exactly three binary bits. The octal number 245 means: (2 x 8^2) + (4 x 8^1) + (5 x 8^0) = 128 + 32 + 5 = 165 in decimal.

2.4 Hexadecimal Number System (Base 16)

The hexadecimal system uses sixteen symbols: 0 to 9 and A to F, where A=10, B=11, C=12, D=13, E=14, F=15. Since 16 = 2^4, each hexadecimal digit corresponds to exactly four binary bits. The hexadecimal number 2AF means: (2 x 16^2) + (10 x 16^1) + (15 x 16^0) = 512 + 160 + 15 = 687 in decimal. Hexadecimal is widely used in memory addresses and colour codes because of its compactness.

3. Number System Conversions

Conversion between number systems is an important skill. Below are the standard methods.

3.1 Decimal to Binary

Repeatedly divide the decimal number by 2 and record the remainders from bottom to top. For example, to convert 45 to binary: 45 / 2 = 22 remainder 1; 22 / 2 = 11 remainder 0; 11 / 2 = 5 remainder 1; 5 / 2 = 2 remainder 1; 2 / 2 = 1 remainder 0; 1 / 2 = 0 remainder 1. Reading remainders bottom-up gives 101101. Hence 45 = 101101 in binary.

3.2 Binary to Decimal

Multiply each bit by its positional power of 2 and add. For 1011: (1 x 2^3) + (0 x 2^2) + (1 x 2^1) + (1 x 2^0) = 8 + 0 + 2 + 1 = 11.

3.3 Decimal to Octal and Hexadecimal

Use the same repeated-division method, dividing by 8 or 16 respectively. For example, 45 in octal: 45 / 8 = 5 remainder 5; 5 / 8 = 0 remainder 5, giving 55 in octal.

3.4 Shortcut Conversions

Because 8 = 2^3 and 16 = 2^4, conversions between binary and octal/hexadecimal are easy: - Binary to octal: Group the bits in threes starting from the rightmost bit, then convert each group. - Binary to hexadecimal: Group the bits in fours and convert each group. - Octal/hexadecimal to binary: Replace each digit by its 3-bit or 4-bit binary equivalent.

For example, the binary number 1101101 grouped as 110 110 1 -> 001 101 101 gives 155 in octal. Grouped as 110 1101 -> 0110 1101 gives 6D in hexadecimal.

4. Binary Arithmetic

Binary numbers can be added, subtracted, multiplied and divided using rules analogous to decimal arithmetic.

4.1 Binary Addition

The rules are: 0 + 0 = 0; 0 + 1 = 1; 1 + 0 = 1; 1 + 1 = 0 with a carry of 1. For example, adding 1011 and 1101: 1011 + 1101 = 11000 (which is 24 in decimal, equal to 11 + 13).

4.2 Binary Subtraction

The rules are: 0 - 0 = 0; 1 - 0 = 1; 1 - 1 = 0; 0 - 1 requires borrowing 1 from the next higher bit. For example, 1101 - 1011 = 0010 (13 - 11 = 2). Subtraction can also be performed by adding the two's complement of the subtrahend, which is the method actually used in computers.

5. Representation of Negative Numbers

Signed numbers can be represented in three ways: sign-magnitude, one's complement and two's complement.

5.1 Sign-Magnitude Representation

The most significant bit (MSB) is used as a sign bit: 0 for positive and 1 for negative. The remaining bits store the magnitude. For example, in an 8-bit system, +45 is 00101101 and -45 is 10101101. This method is simple but has the drawback of two representations for zero (00000000 and 10000000).

5.2 One's Complement

Negative numbers are obtained by flipping every bit of the positive number (changing 0 to 1 and 1 to 0). For example, +45 = 00101101, so -45 = 11010010. Zero again has two representations.

5.3 Two's Complement

The two's complement is obtained by adding 1 to the one's complement. For -45: one's complement of 00101101 is 11010010; adding 1 gives 11010011. The two's complement system is preferred because it has a single representation of zero, and subtraction can be performed simply by adding the two's complement. The range of values for an n-bit two's complement number is from -2^(n-1) to +2^(n-1) - 1.

6. Floating-Point Representation

Real numbers (numbers with a fractional part) are stored in floating-point form, which is analogous to scientific notation. A floating-point number has two parts: a mantissa (or significand) containing the significant digits, and an exponent showing the power of the base. For example, 1234.56 can be written as 0.123456 x 10^4, where 0.123456 is the mantissa and 4 is the exponent.

The most widely used standard is IEEE 754. In the single-precision (32-bit) format, 1 bit is used for the sign, 8 bits for the biased exponent, and 23 bits for the mantissa. In double-precision (64-bit) format, the allocation is 1 bit for sign, 11 bits for the exponent and 52 bits for the mantissa. Floating-point representation allows a huge range of values, but because the mantissa has limited precision, some decimal fractions (such as 0.1) cannot be stored exactly. This is why computations with floating-point numbers often produce tiny rounding errors.

7. Character Encoding Schemes

Numbers alone are not enough; computers must also store text. Character encoding maps each character to a unique code.

7.1 ASCII

The American Standard Code for Information Interchange (ASCII) uses 7 bits, giving 128 codes for English letters, digits, punctuation and control characters. For example, 'A' is 65, 'a' is 97 and '0' is 48. An extended 8-bit version provides 256 codes.

7.2 ISCII

The Indian Script Code for Information Interchange (ISCII) was developed to represent Indian languages such as Hindi, Tamil and Bengali. It is an 8-bit code that can encode characters of all major Indian scripts.

7.3 Unicode

Unicode is a universal encoding standard that represents characters from virtually every written language in the world, including emojis and symbols. UTF-8, a popular Unicode encoding, uses a variable number of bytes per character so that ASCII text remains compatible. For example, the Hindi character "рдХ" and the English letter "A" both have unique Unicode code points. Unicode solves the problem of representing multiple scripts in a single document.

Quick Revision Tables

Table 1: Number Systems Summary

Number System Base Digits Used Example
Decimal 10 0-9 245
Binary 2 0, 1 11110101
Octal 8 0-7 365
Hexadecimal 16 0-9, A-F F5A2

Table 2: Common Character Codes

Character ASCII Code
A 65
Z 90
a 97
z 122
0 48
9 57
space 32

Mind Map

flowchart TD A[Data Representation] --> B[Number Systems] A --> C[Negative Numbers] A --> D[Floating Point] A --> E[Character Encoding] B --> B1[Decimal Base 10] B --> B2[Binary Base 2] B --> B3[Octal Base 8] B --> B4[Hex Base 16] B --> B5[Conversions] C --> C1[Sign-Magnitude] C --> C2[1s Complement] C --> C3[2s Complement] D --> D1[Mantissa] D --> D2[Exponent] D --> D3[IEEE 754] E --> E1[ASCII] E --> E2[ISCII] E --> E3[Unicode UTF-8]

Important Diagrams (SVG)

Diagram 1: Conversions Among Number Systems

Number System Conversions DECIMAL Base 10 BINARY Base 2 OCTAL Base 8 HEXADECIMAL Base 16 Group bits 3s / 4s Binary <-> Octal: group 3 bits | Binary <-> Hex: group 4 bits Golden Rule: Divide by base for decimal to base conversion; multiply by positional powers for base to decimal.

Diagram 2: Two's Complement of a Number

Two's Complement of +45 (8-bit) +45 = 0 0 1 0 1 1 0 1 Step 1: Invert all bits 1s complement = 1 1 0 1 0 0 1 0 Step 2: Add 1 -45 = 1 1 0 1 0 0 1 1 MSB = 1 indicates a negative number. To check, take the two's complement again. Range of 8-bit two's complement: -128 to +127 Golden Rule: Two's complement = invert every bit, then add 1. It gives a unique zero and simplifies subtraction.

Common Mistakes

  1. Confusing bases: Reading binary 101 as "one hundred and one" instead of decimal 5. Always remember the base when interpreting digits.
  2. Wrong remainder order in conversion: When converting decimal to binary by repeated division, remainders are read bottom-to-top, not top-to-bottom.
  3. Incomplete grouping: When converting binary to octal or hexadecimal, forgetting to pad the leftmost group with leading zeros so that it has 3 or 4 bits.
  4. Adding 1 before inverting in two's complement: The correct order is invert first, then add 1. Doing it the other way gives the wrong result.
  5. Thinking ASCII is 8-bit only: Standard ASCII uses 7 bits (128 characters); the 8-bit version is an extension. Also remembering only uppercase codes but not lowercase ('a' is 97, not 65).
  6. Believing all decimal fractions are exact: Values like 0.1 cannot be stored exactly in binary floating point, so equality tests on floats can fail.
  7. Confusing the sign bit with magnitude: In sign-magnitude form the MSB is only a sign indicator; it must not be included in the magnitude calculation.

Exam Tips

  1. Practise conversions thoroughly: Decimal to binary/octal/hex and the reverse, plus the binary to octal/hex grouping shortcuts, as these are the most frequently asked numerical questions.
  2. Remember hexadecimal letters: A=10, B=11, C=12, D=13, E=14, F=15.
  3. For negative numbers, verify with a sanity check: Take the two's complement you obtained and convert it back to decimal to confirm the original value.
  4. Use the power table of 2 up to 2^10 = 1024 so that binary-to-decimal conversions are fast and error-free.
  5. Memorise the ASCII codes of 'A' (65), 'a' (97) and '0' (48); many questions ask for derived codes.
  6. For IEEE 754 questions, remember the bit allocations: single precision 1+8+23, double precision 1+11+52.
  7. Always state the base as a subscript (e.g., 101101_2) in answers to avoid ambiguity.

Conclusion

Data representation is the bridge between human information and machine storage. Binary numbers are the native language of computers, while octal and hexadecimal provide convenient shorthand. Negative numbers are handled elegantly using two's complement, and real numbers use the floating-point format with its inherent trade-off between range and precision. Character codes such as ASCII, ISCII and Unicode enable computers to store and exchange text across the world. These concepts underpin everything a computer does; in the next chapter we will see how the same binary logic is organised into gates and boolean algebra, which form the electronic heart of the processor.