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 29 Letter
29 A
28 A-
27 B+
26 B
25 B-
24 C+
23 C
22 C-
21 D+
20 D
19 D-
 Less than 19 F

New Concepts to be applied for the assignment

Part I: Number conversions (8 marks: Half marks for the answer, half marks for showing your work)

  1. 110012 (binary) to hexadecimal

 

        

        Answer:

  1. 6410 (decimal) to hexadecimal

 

 

          Answer:

  1. 448 (octal) to hexadecimal

 

 

        Answer:

  1. 25.510 (decimal) to binary

 

 

        Answer:

Part II: Non-decimal based math (6 marks: Half marks for the answer, half marks for showing your work)

Perform the following binary additions and subtractions using regular base two subtraction and not by using complements.  Assume a four bit architecture for the computer. 

   0110   0101   1000
  +0010   -0011   -0011
Binary result          

Part III: Complements (6 marks: 1 mark for each empty cell)

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

 

Original binary value

One’s complement value

Two’s complement value

First example   01000    
Second example    11011  
Third example      11111

 

 

Part IV: Non-decimal based math (4 marks: Half marks for the answer, half marks for showing your work)

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

  One's complement approach   
         
  0110
- 0100

Show your work here:

 

 

 

Answer (One's complement): 

Answer (Binary):                   

  Two's complement  approach
         
  0010
- 0100

Show your work here:

 

 

 

Answer (Two' complement):

Answer (Binary):                 

 

 

 

Part V: Logic (5 marks)

Perform the following logical operations.

AND

  T F T F T
AND T T T F T
           

 

OR

  T F T F T
OR T T T F T
           

 

XOR

  T F T F T
XOR T T T F T
           

 

NAND

  T F T F T
NAND T T T F T
           

 

NOR

  T F T F T
NOR T T T F T