HW1DataRep

# HW1DataRep - a 1101& 1110 b 1011 | 1001 c 1001 ^ 1011 d...

This preview shows pages 1–2. Sign up to view the full content.

CS 30 HW #1 - Binary representation Conversions: 1. Convert the decimal number 55 into: a) binary: b) hex: c) octal: 2 a) What decimal number does this unsigned binary number represent: 1111 1111 1011 1101 b) What decimal number does this two's complement binary number represent: 1111 1111 1011 1101 3 a) What is the range of decimal values stored by an 8-bit unsigned binary number? b) What is the range of decimal values stored by an 8-bit two's complement binary number? Addition / Subtraction 4. Solve the following 8-bit addition using binary. Indicate whether or not it experienced an overflow and a carry. 12 + 9 5. Solve the following 8-bit subtraction using binary. Indicate whether or not it experienced an overflow and a carry. 12 - 9 Multiplication 6. Write out the work for the following multiplication using binary. 7 * 5 Bit-wise operations 7. Give the answers to the following bitwise operations

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: a) 1101 & 1110 b) 1011 | 1001 c) 1001 ^ 1011 d) 1011 >> 2 e) ~0110 8. Each operation is written in Java or C, whichever you know. The variables are all integers. Rewrite the line to use a bitwise operation. a) x * 2 b) y / 64 c) z % 16 Errors Given your new knowledge of binary representation and limited bit width, answer the following questions. 9. What happens when the result of an addition or subtraction does not fit into the number of bits provided? 8. What would happen if you executed the following code: Note: unsigned int means an integer being interpreted with unsigned numbers, as we learned at the beginning with binary. Java does not have such a type, but C does. void countdown(int x) { printf("Countdown: "); for(unsigned int i=x;i>=0;i++) printf("%d, ",i); printf(". ... Blastoff!"); }...
View Full Document

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern