Assignment 1
Assignment 1
6. Write a code segment that uses shifts to multiply the unsigned int x by 36. 7. Using an 8-bit word, find the binary representation of -39 in a. two's complement b. ones' complement c. sign-magnitude 8. Using a 16-bit word, find the binary representation of -39 in a. two's complement b. ones' complement c. sign-magnitude
9. Assume that a short is represented by 11 bits and an int is represented by 17 bits. What is the output generated by the following code segment:
int x = 3245; int y = -3245; short sx = (short)x; short sy = (short)y; printf("%d %d %d %d\n",x, y, (int)sx, (int)sy); printf("%x %x %x %x\n",x, y, (int)sx, (int)sy); printf("%u %u %u %u\n",x, y, (int)sx, (int)sy);
You may use a calculator to generate the values, but you must show how you calculated them. 10. Dell computers have a unique alpha-numeric service tag consisting of digits and upper case letters. When you call Dell technical support, they would like to know the service tag number so that they can appropriately route your call. One way to automate this is to have you type in your service tag number. Since there is no convenient way to uniquely type letters on a standard telephone keypad, Dell also gives you an express code, which is a decimal number calculated from the service tag. The calculation algorithm is simple: the service tag is treated as a base-36 number, where A=10, B=11, etc. Find the express code that corresponds to the service tag: M7D3XY1. You must show how you got your answer.