CSCI 1320 - Assignment #2



This assignment has two parts. The first part will have you doing some simple numeric conversions between bases and operations on binary numbers to show that you understand what is going on with them. After that, you will write a short program just to make sure that you have the ability to write, compile, and execute a C program.

Part 1:

A. Convert the following values to hexadecimal. You can feel free to go to binary first then to hex on some.
1. 10110010011011010101 (binary)
2. 1759 (decimal)

B. Now assume that you are dealing with an 16 bit signed number and write the following values in hex.
1. 225 (decimal)
2. -178 (decimal)

C. Run through how you would find this product the "fast" way using binary numbers. (Assume you have a large number of bits here so you don't lose the higher ones.)
11010101*00101001

Part 2: Write a C program that does some of the things from part 1 and prints out the results. For A you only need to do 2. For B do both. For C, use hex notation to put the values into variables and print the product in hex as well.

After you have done this, I want you to write code printing the character values of 45, 56, 98, and 150 followed by the integer values of the characters ' ' (space), 'a', 'B', 'y', and '1'.

Submission: Because this assignment has two parts, you will need to submit them separately. I would like you to give me part 1 in print, either electronic or hand written, just make sure that I can figure out what you are doing either way. Also note that I need to have this part in my hands before I leave on Wednesday which could be as early as 5pm or so. For the second part of the assignment I want you to use the Java submission application that I have written. If you are on one of the lab machines you can run this program by running the command /users/mlewis/Local/HTML-Documents/Grades/GradeCheck.bat. If you are in your room, you can download the file GradeCheck.jar at http://www.cs.trinity.edu/~mlewis/Grades. While you are in the directory where you put that jar file enter the command 'java -cp GradeCheck.jar SubmissionApp rmi://hyperion.cs.trinity.edu:1099/SubmitServer'. THis will run the Java program and tell it where to look for the server. If you installed Java with Cygwin it should work nicely from that command line. Otherwise under Windows you will have to make sure that you have a Java installation on your computer. You can come talk to me about that though I think that Cygwin is the easiest way to go.

Answers to Part 1:

Part 1:

A. Convert the following values to hexadecimal. You can feel free to go to binary first then to hex on some.
1

1011
0010
0110
1101
0101
B
2
6
D
5

2. 1759=1024+735=1024+512+223=1024+512+128+95=1024+512+128+64+16+8+4+2+1=11011011111

0110
1101
1111
6
D
F

B. Now assume that you are dealing with an 16 bit signed number and write the following values in hex.
1. 225 (decimal)=0000 0000 1110 0001=00E1
2. 178 (decimal)=0000 0000 1011 0010=00B2
-178 (decimal)=1111 1111 0100 1110=FF4E

0000
0000
1011
0010
+1111
1111
0100
1110
0000
0000
0000
0000

C. Run through how you would find this product the "fast" way using binary numbers. (Assume you have a large number of bits here so you don't lose the higher ones.)
11010101*00101001

11010101
*00101001
11010101
11010101000
1101010100000
10001000011101