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

 

CPSC 231: Assignment 2 (Worth 4%)

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

 

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

  100010 42 22
255   377 FF
256 100000000   100
16.25 10000.010 20.2  

 

 

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

Perform the following unsigned binary additions and subtractions using four bits.

 

1

0

1

    1 0 1 1

 

 

1

0

0

1

+

0

0

1

1

  - 0 0 1 0

 

-

0

1

1

                                 

 

 

Part III: Complements (3 marks)

Perform the necessary conversions between the three binary representations 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

 01011 01011  
-01111   10001
  10111 11000

 

 

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

 

           

 

New Concepts to be applied for the assignment