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

CPSC 231: Assignment 2 (Worth 3%)

Score out of 29 Letter grade
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. 0111012 (binary) to octal

 

        

        Answer:

 

  1. 7516 (hexadecimal) to decimal

 

 

          Answer:

 

  1. 1048 (octal) to  hexadecimal

 

 

        Answer:

 

  1. 153.2510 (decimal) to hexadecimal

 

 

        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 (using a borrow if necessary) with four bits  and not by using complements.

   0111   1010   1101
  +0001   -0010   -0110
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

Ones complement value

Twos complement value

First example 01111    
Second example   10000  
Third example     10110

 

 

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   
         
  0010
- 0101

Show your work here:

 

 

 

Answer (One's complement):

Answer (Binary):                  

 

  Two's complement  approach
         
  0110
- 0011

Show your work here:

 

 

 

Answer (Two' complement): 

Answer (Binary):                 

 

 

 

Part V: Logic (5 marks)

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
           

As a reminder, you are not allowed to work in groups for this class.   Copying the work of another student will be regarded as academic misconduct (cheating).  For additional details about what is and is not okay for this class please refer to the following link.