Skip to main content

Welcome to a Grasp lesson

Create a free account to keep studying and create your own study path.

Lesson 25

Number Systems & Signed Integers

Recommended resources

Welcome to the first lesson of Module 4, Digital Logic. Having built a strong mathematical foundation in Modules 1, 2, and 3, we now shift our focus to the fundamental principles that govern the design and operation of digital computers. While the previous lesson on Bayes' theorem concluded our exploration of advanced probability, this new module takes us into the heart of computer science hardware.

Before we can delve into designing logic circuits with Boolean algebra, we must first understand the language of computers: binary numbers. This lesson establishes that essential groundwork. We will explore how computers represent not just positive numbers but also negative ones. Your goal for this session is to master the conversion between different number systems—binary, octal, and hexadecimal—and to understand the crucial signed integer representations, particularly 1's and 2's complement. These concepts are not just theoretical; they are the bedrock for the computer arithmetic and architecture topics you will encounter later.

1. Positional Number Systems: The Language of Numbers

All number systems we commonly use, including the decimal system (base 10), are positional. This means the value of a digit depends on its position within the number. For example, in the number 348, the '3' represents 3 hundreds (), the '4' represents 4 tens (), and the '8' represents 8 ones ().

Digital systems, being built from simple on/off switches, operate most naturally in the binary (base-2) system, which uses only two digits: 0 and 1. For convenience and readability, programmers and engineers also use the octal (base-8) and hexadecimal (base-16) systems, as they group binary digits neatly.

The following video provides an excellent introduction to these four number systems and demonstrates the standard method for converting a decimal number into other bases.

Number Systems Introduction - Decimal, Binary, Octal & Hexadecimal

This video from The Organic Chemistry Tutor clearly explains the concept of different number bases and walks through the "successive division" method, which is a fundamental algorithm for number conversion.

Please watch these segments to understand the core conversion techniques: Introduction to Number Systems: First, watch the overview from the beginning to familiarize yourself with the bases and symbols of the decimal, binary, octal, and hexadecimal systems. Decimal to Binary: Pay close attention to the conversion of 348 to binary using successive division, from this section. Notice how the remainders are collected from bottom to top to form the final binary number. Decimal to Octal: Next, see the same method applied for octal conversion by dividing by 8, from this segment. Decimal to Hexadecimal: Finally, watch the conversion to hexadecimal from this part. Note how remainders greater than 9 are represented by letters (A-F).

To convert a number from any base to decimal, you use the polynomial expansion method. You multiply each digit by its positional value (the base raised to the power of the position index) and sum the results.

For example, to convert to decimal:

Since C represents 12 in hexadecimal:

This is the inverse of the process shown in the video.


2. Fast Conversions: The Binary-Octal-Hex Shortcut

For GATE, speed is essential. Direct conversions between binary, octal, and hexadecimal are common and can be done much faster than by going through decimal as an intermediate step. This shortcut works because their bases are powers of 2 ( and ).

  • Binary to Octal: Group binary digits into sets of three, starting from the radix point (the decimal point). Pad with leading or trailing zeros if necessary. Convert each 3-bit group to its single octal digit equivalent.

    • Example: Convert to octal.
      • Group integer part (right to left): 1 011 011 101 -> 001 011 011 101
      • Group fractional part (left to right): 11 -> 110
      • Convert each group: (1)(3)(3)(5) . (6)
      • Result:
  • Binary to Hexadecimal: The process is identical, but you group binary digits into sets of four.

    • Example: Convert to hexadecimal.
      • Group integer part: 10 1101 1101 -> 0010 1101 1101
      • Group fractional part: 11 -> 1100
      • Convert each group: (2)(D)(D) . (C)
      • Result:
  • Octal/Hexadecimal to Binary: Simply reverse the process. Convert each octal/hex digit into its 3-bit/4-bit binary equivalent, maintaining the order.


3. Representing Signed Integers

So far, we've only dealt with unsigned (non-negative) numbers. To represent negative numbers, we need a convention. In all standard systems, the Most Significant Bit (MSB) is used as the sign bit: 0 for positive and 1 for negative.

How the remaining bits (the magnitude) are represented defines the system. The three main representations are Sign-Magnitude, 1's Complement, and 2's Complement.

The following video provides a comprehensive explanation of these three systems. It's crucial to understand their definitions, ranges, and especially the methods for finding the complements.

1's complement and 2's complement | Signed Binary Numbers Explained

This video by "ALL ABOUT ELECTRONICS" is a detailed guide to signed binary numbers. It clearly explains the mechanics and limitations of each representation system, which is vital for GATE questions.

Please watch the video carefully, focusing on these key parts: Unsigned vs. Signed: Watch the introduction from the beginning to understand the fundamental difference between unsigned and signed numbers and the role of the MSB as a sign bit. Sign-Magnitude Form: This section (watch here) explains the most intuitive representation. Pay close attention to its major drawback: two representations for zero (+0 and -0). 1's Complement: Learn how to find the 1's complement by inverting bits from this segment. Note that this system also has two representations for zero. 2's Complement: This is the most important part of the video (watch here). The instructor explains three methods for finding the 2's complement. The shortcut method (copying bits from LSB up to the first '1', then inverting the rest) is particularly fast and useful for exams. Also, grasp the key advantage: a single, unique representation for zero. A Special Case: Finally, watch the brief discussion on what happens when you take the 2's complement of the most negative number from this part. This is a classic edge case that can appear in tricky GATE questions.

Summary of n-bit Signed Number Representations

Let's consolidate the key properties for an n-bit number, as this is a frequent source of GATE questions.

Representation Range of Values Zero Representation(s) How to get -X from +X
Sign-Magnitude Two (e.g., 1000, 0000 for 4 bits) Flip the sign bit.
1's Complement Two (e.g., 1111, 0000 for 4 bits) Invert all bits (bitwise NOT).
2's Complement One (0000) Invert all bits and add 1.

Notice the asymmetric range of the 2's complement system—it can represent one more negative number than positive numbers. This is a direct consequence of having only one representation for zero. This system is the standard for integer arithmetic in virtually all modern computers because it makes subtraction as simple as adding a negative number, simplifying hardware design.


Conclusion

In this foundational lesson for Digital Logic, we have covered the essential ways computers represent numerical data. You now have the tools to confidently move between the number systems used in computer science and to interpret signed binary values.

Key Takeaways:

  • Number Conversions: You can convert numbers between decimal, binary, octal, and hexadecimal using the successive division method (to other bases) and polynomial expansion (to decimal).
  • Fast Conversions: For conversions between binary, octal, and hexadecimal, use the fast-grouping method (groups of 3 for octal, 4 for hex).
  • Signed Representations: The most significant bit (MSB) acts as a sign bit (0=positive, 1=negative).
  • 1's vs. 2's Complement: While both are methods for representing negative numbers, 2's complement is superior and universally used in modern CPUs because it has a single representation for zero and simplifies arithmetic logic.
  • Ranges: Be mindful of the precise range of numbers that can be represented in bits for each system, especially the unique asymmetrical range of 2's complement.

In our next lesson, we will build directly on this foundation. We will explore Topic 4.8: Computer Arithmetic, where you will see exactly how a processor uses 2's complement representation to perform addition and subtraction and how it detects conditions like overflow.