Data Representation
Module 2
CS 272
Sam Houston State University
Dr. Tim McGuire


Positional Number Systems

Binary, Octal, & Hexadecimal Numbers Problems with Binary Octal and Hexadecimal
decimal 0  1   2   3   4   5   6   7    8    9   10
binary  0  1  10  11 100 101 110 111 1000 1001 1010
octal   0  1   2   3   4   5   6   7   10   11   12
Hexadecimal
decimal 0  1   2   3   4   5   6   7    8    9   10   11   12
binary  0  1  10  11 100 101 110 111 1000 1001 1010 1011 1100
hex     0  1   2   3   4   5   6   7    8    9    A    B    C
Conversions 2BD416 = 2x163 + Bx162 + Dx161 + 4x160
  = 2x4096 + 11x256 + 13x16 + 4x1
  = 8192 + 2816 + 208 + 4 = 11,22010
11172 ¸ 16 = 698 r 4
  698 ¸ 16 = 43 r 10 (Ah)
   43 ¸ 16 = 2 r 11 (Bh)
    2 ¸ 16 = 0 r 2

Converting the remainders to hex and putting them together in reverse order, we get
1117210 = 2BA416

Conversions Between Hex and Binary 0011 1010 1010 = 3AAh Conversions Between Hex and Octal 3F7416 = 0011 1111 0111 0100
= 0 011 111 101 110 100 = 0375648
Exercise: Addition and Subtraction  2546
+1872
 4418
 5B39
+7AF4
 D62D
 100101111
+000110110
 101100101
A Note on Notation Two's Complement Arithmetic The Fabulous Four-bit Machine (FFM) 0000, 0001, 0010, 0011, 0100, 0101, 0110, 0111,
1000, 1001, 1010, 1011, 1100, 1101, 1110, 1111
Unsigned Integers Signed Integers Sign and Magnitude One's Complement Two's Complement  0100
 1011
10000
Complementing the Complements Moving past 4 bits Decimal Interpretation Signed and Unsigned Interpretations Hex     Unsigned decimal     Signed decimal
0000             0                     0
0001             1                     1
0002             2                     2
. . .         . . .                 . . .
0009             9                     9
000A            10                    10
. . .         . . .                 . . .
7FFE         32766                 32766
7FFF         32767                 32767
8000         32768                -32768
8001         32769                -32767
. . .         . . .                 . . .
FFFE         65534                    -2
FFFF         65535                    -1
Example Thus, AX contains -500 Character Representation ASCII Code Input and Output Table of ASCII Codes