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 19 Letter
19 A
18 A-
17 B+
16 B
15 B-
14 C+
13 C
12 C-
11 D+
10 D
  9 D-
 Less than 9 F

 

New Concepts to be applied for the assignment

 

Part I: Number conversions (4 marks: Show all your work)

  1. 110012 (binary) to octal

 

        

        Answer:

  1. 3210 (decimal) to hexadecimal

 

 

          Answer:

  1. 328 (octal) to decimal

 

 

        Answer:

  1. 12.7510 (decimal) to binary

 

 

        Answer:

 

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

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

   0110   0101   1000
  +0010   -0010   -0001
Binary result          

 

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

 

Original binary value

One’s complement value

Two’s complement value

First example   01000  01000  
Second example   00100    11100
Third example    00100  00100

 

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

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

  One's complement  negate and add   
         
  0111
- 0100

Show your work here:

 

 

 

Answer (One's complement): 

Answer (Binary):                   

 

 

  Two's complement  negate and add   
         
  0001
- 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