Data Representation

Number Systems

  • Human beings use decimal (base 10) number systems for counting and measurements.
  • Computers use binary (base 2) number system, as they are made from binary digital components (known as transistors) operating in two states - on and off.
  • In computing, we also use hexadecimal (base 16) or octal (base 8) number systems, as a compact form for represent binary numbers.

Decimal (Base 10) Number System

  • Decimal number system has ten symbols: 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9, called digits.
  • It uses positional notation. That is, the least-significant digit (right-most digit) is of the order of 10^0 (units or ones), the second right-most digit is of the order of 10^1 (tens), the third right-most digit is of the order of 10^2 (hundreds), and so on. 
  • For example,
                               735 = 7×10^2 + 3×10^1 + 5×10^0

Binary (Base 2) Number System

  • Binary number system has two symbols: 0 and 1, called bits. 
  • It is also a positional notation.
  • for example, 10110B = 1×2^4 + 0×2^3 + 1×2^2 + 1×2^1 + 0×2^0

Hexadecimal (Base 16) Number System

  • Hexadecimal number system uses 16 symbols: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, and F, called hex digits. It is a positional notation. 
  • For example, A3EH = 10×16^2 + 3×16^1 + 14×16^0

Conversion from Hexadecimal to Binary

  • Replace each hex digit by the 4 equivalent bits, for examples,
          A3C5H = 1010 0011 1100 0101B 
          102AH = 0001 0000 0010 1010B

Conversion from Binary to Hexadecimal

  • Starting from the right-most bit (least-significant bit), replace each group of 4 bits by the equivalent hex digit (pad the left-most bits with zero if necessary), for examples,
          1001001010B = 0010 0100 1010B = 24AH 
          10001011001011B = 0010 0010 1100 1011B = 22CBH

Conversion from Base r to Decimal (Base 10)

  • Given a n-digit base r number: dn-1 dn-2 dn-3 ... d3 d2 d1 d0 (base r), the decimal equivalent is given by: 
                        dn-1 × r^(n-1) + dn-2 × r^(n-2) + ... + d1 × r^1 + d0 × r^0

Conversion from Decimal (Base 10) to Base r

  • Use repeated division/remainder. 
  • For example,
    • To convert 261D to hexadecimal: 
    • 261/16 quotient=16 remainder=5 
    • 16/16 quotient=1 remainder=0 
    • 1/16 quotient=0 remainder=1 
    • (quotient=0 stop) Hence, 261D = 105H

Comments

Popular posts from this blog

Pentium microprocessors

Multilevel Organization of Cache Memory