Lecture notes for the Introduction to Computer Science I by James Tam Return to the course web page

 

CPSC 231: Assignment 2 (Worth 3%)

Grade out of 18 Letter
18 A
17 A-
16 B+
15 B
14 B-
13 C+
12 C
11 C-
10 D+
 9 D
 8 D-
 Less than 8 F

 

New Concepts to be applied for the assignment

 

Part I: Number conversions (4 marks)

Perform the necessary number conversions in order to fill in the missing values in the table below.

Number system

Value in decimal

Value in binary

Value in Octal

Value in Hexadecimal

  110010 62 32
31   37 1F
121 1111001   79
12.75 1100.11 14.6  

 

Part II: Non-decimal based math (3 marks)

Perform the following binary additions and subtractions using four bits.

 

0

1

1

    0 1 0 1

 

 

1

0

0

1

+

0

0

1

0

  - 0 0 0 1

 

-

0

0

1

                                 

 

Part III: Complements (3 marks)

Perform the necessary conversions between the three binary representations (using five bits) in order to fill in the missing values in the table below.

Number system

Unsigned binary value

One’s complement value

Two’s complement value

  01000   01000  
- 00100 +            +11100
    00100   00100

 

Part IV: Non-decimal based math (4 marks)

Perform the following subtractions via the negate and add technique using 4 bits.   Show the final result both in unsigned binary and in the appropriate signed representation.                                                                                 

  One's complement  negate and add    Two's complement negate and add
                         

 

  0 1 0 1

 

 

  0 0 1 1

 

- 0 1 0 0

 

 

- 0 1 0 0

1's

         

 

2's

         

U/S

         

 

U/S

         

 

Part V: Logic (5 marks)

Perform the following logical operations.

AND

 

T T T F F F

AND 

F T F T F T

 

           

 

OR

 

T T T F F F

OR 

F T F T F T
             

 

XOR

 

T T T F F F

XOR 

F T F T F T

 

           

 

NAND

 

T T T F F F

NAND 

F T F T F T

 

           

 

NOR

 

T T T F F F

NOR 

F T F T F T