Docsity

Homework 1 with Solution - Security in Computing | CIS 3360, Study notes of Computer Science

Toggle sidebar
bg1
Instructions:
All assignments must be typed; no hand-written assignments will be accepted.
You must name your file as: your_last_name_your_first_name_HW#
Acceptable file formats: .doc, .docx, .pdf
Inside the file, you MUST include your full name, otherwise your HW will not be graded.
Do not just give answer. You must show your work. Otherwise you will not get any points
CIS 3360 – Security in Computing
Spring 2015
Homework 1.1 (50 points)
This solution is prepared by TA Ms. Pei Liu
1) Number conversions - run through the algorithms for each of the following number
conversions, showing each of the steps. If you write a program to automate the process, show the
output of your program AND attach your code (.c or .java) as a separate file.
a) Convert 60510 to binary, octal (base 8) and hexadecimal.
2 |605
|302- 1
|151- 0
|75 - 1
|37- 1
|18- 1
|9- 0
|4- 1
|2- 0
1 – 0
Binary answer = 10010111012
Octal answer = 001 001 011 1012 = 11358
Hexadecimal answer = 0010 0101 11012 = 25D16
b) Convert 101100112 to octal, decimal and hexadecimal.
Decimal answer = 101100112 = 128+0+32+16+0+0+2+1=17910
Octal answer = 010 110 0112 =2638
Hexadecimal answer = 1011 00112 =B316
c) Convert 21BA16 to binary, octal and decimal.
216=0010, 116=0001, B16=1011, A16=1010
Binary answer = 0010 0001 1011 10102
Decimal answer = 100001101110102= 863410
Octal answer = 010 000 110 111 0102 =206728
pf3

Partial preview of the text

Download Homework 1 with Solution - Security in Computing | CIS 3360 and more Study notes Computer Science in PDF only on Docsity!

Instructions:  All assignments must be typed; no hand-written assignments will be accepted.  You must name your file as: your_last_name_your_first_name_HW#  Acceptable file formats: .doc, .docx, .pdf  Inside the file, you MUST include your full name, otherwise your HW will not be graded.  Do not just give answer. You must show your work. Otherwise you will not get any points

CIS 3360 – Security in Computing

Spring 2015

Homework 1.1 (50 points)

This solution is prepared by TA Ms. Pei Liu

  1. Number conversions - run through the algorithms for each of the following number conversions, showing each of the steps. If you write a program to automate the process, show the output of your program AND attach your code (.c or .java) as a separate file.

a) Convert 605 10 to binary, octal (base 8) and hexadecimal.

2 | |302- 1 |151- 0 |75 - 1 |37- 1 |18- 1 |9- 0 |4- 1 |2- 0 1 – 0

Binary answer = 1001011101 2 Octal answer = 001 001 011 101 2 = 1135 8 Hexadecimal answer = 0010 0101 1101 2 = 25D 16

b) Convert 10110011 2 to octal, decimal and hexadecimal. Decimal answer = 10110011 2 = 128+0+32+16+0+0+2+1=179 10 Octal answer = 010 110 011 2 =263 8 Hexadecimal answer = 1011 0011 2 =B3 16 c) Convert 21BA 16 to binary, octal and decimal. 216 =0010, 1 16 =0001, B 16 =1011, A 16 = Binary answer = 0010 0001 1011 1010 2 Decimal answer = 10000110111010 2 = 8634 10 Octal answer = 010 000 110 111 010 2 =20672 8

  1. Unsigned Binary Arithmetic - perform each of the following operations using an 8-bit unsigned integer storage scheme and indicate the final answer and whether or not an overflow has occurred.

a) 10110101 + 00011001 = 11001110 (no overflow) 10110101

  • 00011001

11001110 (no overflow as no 1 came out of most significant bit) b) 10010001 + 10111111 = 01010000 (overflow) 10010001

  • 10111111

1 01010000 (overflow as 1 came out of most significant bit)

  1. Two's Complement Binary Arithmetic - perform each of the following operations using an 8-bit signed integer storage scheme (two's complement) and indicate the final answer and whether or not an overflow has occurred.

a) 01100001 + 00111111 = 10100000 (overflow) 01100001

  • 00111111

10100000 (overflow: as 1 came into most significant bit but a 0 came out of most significant bit) [Adding two positive number gives negative result] b) 10111111 + 10010101 = 01010100 (overflow) 10111111

  • 10010101

1 01010100 (overflow: as 0 came into most significant bit but a 1 came out of most significant bit) [Adding two negative number gives positive result] )

  1. Modular Arithmetic - perform each of the following modular operations. Determine the unique number (mod n) in between 0 and n - 1, inclusive, that each of these expressions evaluates to, for the particular n in each problem.

a) (305 - 4(53) + 7(2^4 )) mod 29 = 2 305 mod 29 = 453 mod29 = (4mod29 * 53mod29) mod29 = (4 * 24) mod29 = 7 2^4 mod29 = (7mod29 * 2^4 mod29) mod29 = 25 (305 - 4(53) + 7(2^4 )) mod 29 = (15-9+25)mod29 = 31mod29 = 2

b) 43 – (8 * 7)(9 - 7) mod 32 = 27 43mod 32 = 11 (87)(9-7)mod 32 = 562 mod 32 = 16 43 – (8 * 7)(9 - 7) mod 32 = (11 -16) mod 32 = (-5+32)mod 32 = 27