CSSE 132 Homework Review — Staged for Instructor Review

HW01: 16-Bit Number Representations

This review follows HW01's original numbering so you can compare each question directly with your submitted work.

What This Homework Practiced

HW01 practiced converting 16-bit values among decimal, binary, and hexadecimal. Before calculating, identify whether the value is unsigned or signed two's complement; the same bits can have different decimal meanings.

Key Ideas to Remember

ConversionStudent process
Decimal → binaryDivide by 2 repeatedly; read remainders bottom to top.
Decimal → hexadecimalDivide by 16 repeatedly; use A–F for remainders 10–15.
Binary ↔ hexadecimalOne hexadecimal digit is exactly one four-bit nibble.
Binary or hex → decimalAdd the corresponding powers of 2 or powers of 16.
Negative signed valueKeep 16 bits, flip every bit, then add 1.

Unsigned 16-bit values range from 0 to 65,535. Signed 16-bit values range from -32,768 to 32,767. Always pad a requested 16-bit representation with leading zeros.

Question 1: Unsigned Decimal to Binary and Hexadecimal

1.1: 65,533

Binary: divide by 2, keeping each remainder.

65533 ÷ 2 = 32766 remainder 1
32766 ÷ 2 = 16383 remainder 0
16383 ÷ 2 =  8191 remainder 1
 8191 ÷ 2 =  4095 remainder 1
 4095 ÷ 2 =  2047 remainder 1
 2047 ÷ 2 =  1023 remainder 1
 1023 ÷ 2 =   511 remainder 1
  511 ÷ 2 =   255 remainder 1
  255 ÷ 2 =   127 remainder 1
  127 ÷ 2 =    63 remainder 1
   63 ÷ 2 =    31 remainder 1
   31 ÷ 2 =    15 remainder 1
   15 ÷ 2 =     7 remainder 1
    7 ÷ 2 =     3 remainder 1
    3 ÷ 2 =     1 remainder 1
    1 ÷ 2 =     0 remainder 1

Reading the remainders from bottom to top gives 1111 1111 1111 1101.

Hexadecimal: divide by 16.

65533 ÷ 16 = 4095 remainder 13 = D
 4095 ÷ 16 =  255 remainder 15 = F
  255 ÷ 16 =   15 remainder 15 = F
   15 ÷ 16 =    0 remainder 15 = F

Reading the remainders from bottom to top gives F F F D, or 0xFFFD. Grouping the binary confirms it: 1111 1111 1111 1101 = F F F D.

Check: 15×4096 + 15×256 + 15×16 + 13 = 65,533.

1.2: 256

Binary:

256 ÷ 2 = 128 remainder 0
128 ÷ 2 =  64 remainder 0
 64 ÷ 2 =  32 remainder 0
 32 ÷ 2 =  16 remainder 0
 16 ÷ 2 =   8 remainder 0
  8 ÷ 2 =   4 remainder 0
  4 ÷ 2 =   2 remainder 0
  2 ÷ 2 =   1 remainder 0
  1 ÷ 2 =   0 remainder 1

Reading the remainders from bottom to top gives 100000000. Padding to 16 bits gives 0000 0001 0000 0000.

Hexadecimal:

256 ÷ 16 = 16 remainder 0
 16 ÷ 16 =  1 remainder 0
  1 ÷ 16 =  0 remainder 1

Reading the remainders from bottom to top gives 100; pad to four hex digits: 0x0100. The single 1 at binary position 8 checks that the value is 28 = 256.

Question 2: Signed Decimal to Binary and Hexadecimal

For a negative value, first find the positive 16-bit pattern, then flip all 16 bits and add 1. The resulting leading 1 is the sign bit.

2.1: -298

First convert positive 298 to binary.

298 ÷ 2 = 149 remainder 0
149 ÷ 2 =  74 remainder 1
 74 ÷ 2 =  37 remainder 0
 37 ÷ 2 =  18 remainder 1
 18 ÷ 2 =   9 remainder 0
  9 ÷ 2 =   4 remainder 1
  4 ÷ 2 =   2 remainder 0
  2 ÷ 2 =   1 remainder 0
  1 ÷ 2 =   0 remainder 1

Reading from bottom to top gives 100101010, so positive 298 is 0000 0001 0010 1010 in 16 bits. Its hexadecimal conversion is:

298 ÷ 16 = 18 remainder 10 = A
 18 ÷ 16 =  1 remainder  2
  1 ÷ 16 =  0 remainder  1

Reading upward gives 0x12A, or 0x012A in 16 bits. Now take the two's complement:

positive: 0000 0001 0010 1010
flip:     1111 1110 1101 0101
add 1:    1111 1110 1101 0110

Its first bit is 1, so it represents a negative signed value. Grouping the result gives F E D 6: the requested representations are 1111 1110 1101 0110 and 0xFED6.

Check: flip 0xFED6 and add 1 to recover 0x012A = 298.

2.2: 255

Because 255 is positive and fits in the signed 16-bit range, its pattern is the ordinary positive pattern.

255 ÷ 2 = 127 remainder 1
127 ÷ 2 =  63 remainder 1
 63 ÷ 2 =  31 remainder 1
 31 ÷ 2 =  15 remainder 1
 15 ÷ 2 =   7 remainder 1
  7 ÷ 2 =   3 remainder 1
  3 ÷ 2 =   1 remainder 1
  1 ÷ 2 =   0 remainder 1

Reading upward and padding gives 0000 0000 1111 1111.

255 ÷ 16 = 15 remainder 15 = F
 15 ÷ 16 =  0 remainder 15 = F

Reading upward gives FF, or 0x00FF in 16 bits. The leading 0 confirms the signed value is positive.

Question 3: Unsigned Binary to Hexadecimal and Decimal

3.1: 0010 0111 1001 0000

Hexadecimal: group the bits into four-bit nibbles.

0010 0111 1001 0000
  2    7    9    0

So the hexadecimal representation is 0x2790.

Decimal: add the powers of 2 whose bits are 1:

213 + 210 + 29 + 28 + 27 + 24
= 8192 + 1024 + 512 + 256 + 128 + 16 = 10,128

Check: 2×163 + 7×162 + 9×16 = 10,128.

3.2: 0001 1111 1111 1111

0001 1111 1111 1111
  1    F    F    F

Grouping the bits into nibbles gives 0x1FFF. The 1 bits occupy positions 12 through 0:

4096 + 2048 + 1024 + 512 + 256 + 128 + 64 + 32 + 16 + 8 + 4 + 2 + 1
= 213 - 1 = 8,191

Check: 1×4096 + 15×256 + 15×16 + 15 = 8,191.

Question 4: Signed Binary to Hexadecimal and Decimal

4.1: 1000 0000 0000 0000

1000 0000 0000 0000
  8    0    0    0

Grouping gives 0x8000. In a signed 16-bit value, the leftmost bit has weight -215; every other bit is 0. Therefore the signed decimal value is -32,768.

Check: this is the smallest possible signed 16-bit value.

4.2: 1110 1111 1011 1101

1110 1111 1011 1101
  E    F    B    D

Grouping gives 0xEFBD. The sign bit is 1, so find the magnitude by taking the two's complement:

given: 1110 1111 1011 1101
flip:  0001 0000 0100 0010
add 1: 0001 0000 0100 0011

The magnitude is 212 + 26 + 21 + 20 = 4096 + 64 + 2 + 1 = 4,163. Therefore the signed decimal value is -4,163.

Question 5: Unsigned Hexadecimal to Decimal and Binary

5.1: 0x12BD

Convert every hexadecimal digit to its four-bit equivalent:

1    2    B    D
0001 0010 1011 1101

For decimal, expand each hexadecimal place value:

1×163 + 2×162 + 11×161 + 13×160
= 4096 + 512 + 176 + 13
= 4,797

So the requested representations are 4,797 and 0001 0010 1011 1101.

5.2: 0x1EE7

1    E    E    7
0001 1110 1110 0111

1×163 + 14×162 + 14×161 + 7×160
= 4096 + 3584 + 224 + 7
= 7,911

So the requested representations are 7,911 and 0001 1110 1110 0111.

Question 6: Signed Hexadecimal to Decimal and Binary

6.1: 0xFFFF

F    F    F    F
1111 1111 1111 1111

The sign bit is 1. To find the magnitude, flip the 16 bits and add 1:

given: 1111 1111 1111 1111
flip:  0000 0000 0000 0000
add 1: 0000 0000 0000 0001

The magnitude is 1, so the signed decimal value is -1. Adding 1 to 0xFFFF produces 0x0000, which checks the result.

6.2: 0xEC00

E    C    0    0
1110 1100 0000 0000

The sign bit is 1, so take the two's complement:

given: 1110 1100 0000 0000
flip:  0001 0011 1111 1111
add 1: 0001 0100 0000 0000

The magnitude is 0x1400:

1×163 + 4×162 + 0×16 + 0
= 4096 + 1024 = 5,120

Therefore the signed decimal value is -5,120.

Common HW01 Mistakes

Missing leading zeros

Use all 16 bits when the question asks for a 16-bit representation.

Reading remainders forward

The first remainder is the rightmost digit; read repeated-division remainders from bottom to top.

Skipping the add 1

Flipping bits alone is one's complement. Signed negative values need flip and add 1.

Forgetting the interpretation

A leading 1 indicates a negative value only when the question specifies signed two's complement.

What You Should Be Able to Do Now

  • Convert decimal values by repeated division and read remainders in the correct direction.
  • Translate binary and hexadecimal one nibble at a time.
  • Evaluate binary and hexadecimal place values.
  • Build and interpret 16-bit two's-complement values.
  • Check an answer by converting through another representation.

Try It Yourself

  1. Convert unsigned 1,234 to 16-bit binary and hexadecimal.
  2. Convert unsigned 0011 0101 0110 1001 to hexadecimal and decimal.
  3. Convert signed -73 to 16-bit binary and hexadecimal.
  4. Interpret signed 0xF580 as decimal and binary.
Show practice answers
  1. 0000 0100 1101 0010 and 0x04D2.
  2. 0x3569 and 13,673.
  3. 1111 1111 1011 0111 and 0xFFB7.
  4. 1111 0101 1000 0000 and -2,688.