Fiveable

💾Intro to Computer Architecture Unit 2 Review

QR code for Intro to Computer Architecture practice questions

2.1 Binary and hexadecimal number systems

💾Intro to Computer Architecture
Unit 2 Review

2.1 Binary and hexadecimal number systems

Written by the Fiveable Content Team • Last updated September 2025
Written by the Fiveable Content Team • Last updated September 2025
💾Intro to Computer Architecture
Unit & Topic Study Guides

Binary and hexadecimal number systems are the backbone of digital computing. They allow computers to process and store information efficiently, with binary representing the on/off states of electronic circuits and hexadecimal providing a more compact way to express binary values.

Understanding these systems is crucial for anyone working with computers at a low level. From encoding data to representing memory addresses, binary and hexadecimal are essential tools in computer architecture, programming, and digital design.

Number System Conversions

Binary to Decimal Conversion

  • Binary numbers are represented using only two digits, 0 and 1, and each digit represents a power of 2
  • To convert from binary to decimal, multiply each binary digit by its corresponding power of 2 and sum the results
    • Example: Convert 1101₂ to decimal
      1. 1×2³ + 1×2² + 0×2¹ + 1×2⁰
      2. 8 + 4 + 0 + 1
      3. 13₁₀

Decimal to Binary Conversion

  • Decimal numbers are represented using ten digits, 0 through 9
  • To convert from decimal to binary, repeatedly divide the decimal number by 2 and record the remainders in reverse order until the quotient becomes 0
    • Example: Convert 42₁₀ to binary
      1. 42 ÷ 2 = 21 remainder 0
      2. 21 ÷ 2 = 10 remainder 1
      3. 10 ÷ 2 = 5 remainder 0
      4. 5 ÷ 2 = 2 remainder 1
      5. 2 ÷ 2 = 1 remainder 0
      6. 1 ÷ 2 = 0 remainder 1
      7. Reading the remainders in reverse order: 101010₂

Hexadecimal to Decimal Conversion

  • Hexadecimal numbers are represented using 16 digits: 0 through 9 and A through F (representing 10 through 15)
  • Each hexadecimal digit represents a group of four binary digits (bits), and the conversion between binary and hexadecimal is straightforward
  • To convert from hexadecimal to decimal, multiply each hexadecimal digit by its corresponding power of 16 and sum the results
    • Example: Convert 7B₁₆ to decimal
      1. 7×16¹ + 11×16⁰ (B represents 11 in decimal)
      2. 112 + 11
      3. 123₁₀

Decimal to Hexadecimal Conversion

  • To convert from decimal to hexadecimal, repeatedly divide the decimal number by 16 and record the remainders (using A-F for 10-15) in reverse order until the quotient becomes 0
    • Example: Convert 254₁₀ to hexadecimal
      1. 254 ÷ 16 = 15 remainder 14 (E in hexadecimal)
      2. 15 ÷ 16 = 0 remainder 15 (F in hexadecimal)
      3. Reading the remainders in reverse order: FE₁₆

Binary and Hexadecimal Arithmetic

Binary Arithmetic

  • Binary addition follows the same rules as decimal addition, with the additional rule that 1 + 1 = 10 (carry the 1 to the next column)
    • Example: Add 1011₂ and 101₂
      1. 1011₂ + 101₂ = 10000₂ (16 in decimal)
  • Binary subtraction can be performed by using two's complement representation and addition
    • Example: Subtract 101₂ from 1100₂ using two's complement
      1. Two's complement of 101₂ is 011₂
      2. 1100₂ + 011₂ = 1111₂ (15 in decimal)
  • Binary multiplication follows the same rules as decimal multiplication, with the additional rule that 1 × 1 = 1 and 0 × 0 = 0 × 1 = 1 × 0 = 0
    • Long multiplication can be used for larger binary numbers
    • Example: Multiply 1101₂ by 101₂
      1. 1101₂ × 101₂ = 1000001₂ (65 in decimal)
  • Binary division can be performed using long division, similar to decimal division, with the additional rule that the divisor can only be 1 or 0
    • Example: Divide 1010₂ by 10₂
      1. 1010₂ ÷ 10₂ = 101₂ (5 in decimal)

Hexadecimal Arithmetic

  • Hexadecimal arithmetic follows the same rules as decimal arithmetic, with the additional digits A through F representing 10 through 15
  • When a result exceeds 15 (F), carry the appropriate amount to the next column
    • Example: Add 7B₁₆ and 8C₁₆
      1. 7B₁₆ + 8C₁₆ = 107₁₆ (263 in decimal)

Binary vs Hexadecimal Representation

Relationship between Binary and Hexadecimal

  • Each hexadecimal digit represents a group of four binary digits (bits), making it a compact representation of binary numbers
  • This relationship allows for easy conversion between the two systems

Binary to Hexadecimal Conversion

  • The hexadecimal representation of a binary number can be obtained by grouping the binary digits into sets of four (starting from the right) and converting each group to its corresponding hexadecimal digit
    • Example: Convert 101101₂ to hexadecimal
      1. Group binary digits: 10 1101
      2. Convert each group to hexadecimal: 2 D
      3. 101101₂ = 2D₁₆

Hexadecimal to Binary Conversion

  • The binary representation of a hexadecimal digit can be obtained by converting the hexadecimal digit to its decimal equivalent and then converting the decimal to its 4-bit binary representation
    • Example: Convert F3₁₆ to binary
      1. F = 15₁₀ = 1111₂, 3 = 3₁₀ = 0011₂
      2. F3₁₆ = 11110011₂

Importance of Binary and Hexadecimal

Binary in Computer Systems

  • Binary is the fundamental number system used in computer systems because it aligns with the two-state nature of electronic circuits (on/off, high/low voltage)
  • Binary representations are used to encode instructions, memory addresses, and data within a computer system
  • Understanding binary is essential for working with low-level programming and computer architecture
    • Example: Assembly language instructions are often represented in binary or hexadecimal format

Hexadecimal in Programming and Computer Systems

  • Hexadecimal is often used as a compact and human-readable representation of binary numbers, particularly in programming, debugging, and memory addressing
  • Hexadecimal is used to represent memory addresses because it provides a more compact representation than binary, making it easier for humans to read and write
    • Example: Memory addresses in a debugger are typically displayed in hexadecimal format (0x7FFF5000)
  • Hexadecimal is also used to represent color codes in web design and graphics applications, as each color channel (red, green, blue) can be represented by a two-digit hexadecimal number
    • Example: The color red can be represented as #FF0000 in hexadecimal (255, 0, 0 in decimal for RGB)

Importance of Understanding Binary and Hexadecimal

  • Understanding the relationship between binary and hexadecimal is crucial for working with computer systems, as it allows for efficient conversion and interpretation of data between the two number systems
  • Familiarity with binary and hexadecimal is essential for low-level programming, embedded systems, and computer architecture
    • Example: When working with bitwise operations or manipulating individual bits in a program, understanding binary representation is necessary