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

CPSC 231: Assignment 2 (Worth 2%)

Score out of 29 Letter grade Score out of 29 Letter grade
29 A 23 C
28 A- 22 C-
27 B+ 21 D+
26 B 20 D
25 B- 19 D-
24 C+  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. 1010002 (binary) to hexadecimal

 

 

 

         Answer:

 

  1. 678 (octal) to decimal

 

 

 

          Answer:

 

 

  1. 10416 (hexadecimal) to octal

 

 

        Answer:

 

  1. 25.510 (decimal) to octal

 

 

        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.

   0101   1101   1100
  +0010   -0101   -0001
Binary result          

 

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

Perform the necessary conversions between the three binary representations (using six 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 010011    
Second example   100100  
Third example     111111

 

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   
         
  0100
- 0101
Show your work here:

 

 

 

Answer (One's complement):

Answer (Binary):               

 

  Two's complement  approach
         
  0101
- 0011

Show your work here:

 

 

 

Answer (Two' complement):

Answer (Binary):      

 

 

 

Part V: Logic (5 marks)

AND

  T F T F F
AND F F T T F
           

 

OR

  T F T F F
OR F F T T F
           

 

XOR

  T F T F F
XOR F F T T F
           

 

NAND

  T F T F F
NAND F F T T F
           

 

NOR

  T F T F F
NOR F F T T F
           

 

 

 

 

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.