# Spring 2003 ENGR 212 Homework 1 Solution

Solutions are only given for interesting problems.

## Problem 1

Convert the following numbers from decimal into binary and into hexadecimal numbers.

• 212

11010100 or D4

• 2003

11111010011 or 7D3

• 48879

1011111011101111 or BEEF

• 100

1100100 or 64

## Problem 2

Add the following three pairs of unsigned binary numbers.

• ```  1001100
+  11111
1111011
```
• ```      100
+  11110
100010
```
• ```  1001100
+1001100
10011000
```

## Problem 3

Add the following three pairs of 8-bit twos-complement binary numbers. Indicate if the addition results in an overflow.

• ```  10011000
+11110001
10001001 no overflow
```
• ```  01100110
+11001100
00110010  no overflow
```
• ```  01100110
+01100110
1100100  overflow
```

## Problem 4

Add the following three pairs of 16-bit twos complement binary numbers. Indicate if the addition results in an overflow

The numbers are expressed in hexadecimal notation.

• ```   2003
+ 9999
B99C  no overflow
```
• ```   BEEF
+ 1111
D000  no overflow
```
• ```   3AC0
+ 6165
9C25  overflow
```

## Problem 5

Perform the following additions using BCD arithmetic. Assume each 8-bit quantity is a packed-BCD number -- that is, that there are two decimal digits in each byte. Show where the intermediate result was modified because of carry or value greater than 9 to produce the correct final result.

• ```   18
+ 22
```
```    8
+  2
A
+  6    see if result greater than 9
10    carry occurs, keep the 0

1
1
+ 2
4
+ 6    see if result greater than 9
A     no carry occurs, keep the 4

40
```
• ```   77
+ 14
```
• ```   06
+ 66
```

## Problem 6

Create a five-bit gray code sequence of 32 values.