cs61c_fa07_mtReview

# cs61c_fa07_mtReview - CS61c Midterm Review(sp07 Number...

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

CS61c Midterm Review (sp07) Number representation and Floating points Alex Kronrod Number representation (See: Lecture 2, Lab 1, HW#1) KNOW: Kibi (2 10 ), Mebi(2 20 ), Gibi(2 30 ), Tebi(2 40 ), Pebi(2 50 ), Exbi(2 60 ), Zebi(2 70 ), Yobi (2 80 ) Know the Binary (0b), Octal (0), Decimal, Hexadecimal (0x) representation of numbers. o Example: 1111 2 = 17 8 = 15 ten = F hex or 0b1111 = 017 = 15 = 0xF Know how to convert from one base to another. Example: 104 5 =4*5 0 +0*5 1 +1*5 2 = 29 ten Know what is a bit, a Nibble, a Byte, a Word o Example: above example uses a Nibble! The lecture presents the evolution of number representation: sign and magnitude, one’s complement, two’s complement o Sign and Magnitude: *Left most bit represents the sign (0 == positive, 1 == negative), the rest represents magnitude. *In order to negate, flip the left most bit. * Can represent from –(2 N-1 -1) to 2 N-1 -1 Cons: *We have two zeros, namely 0x00000000 and 0x80000000 *Arithmetic is non-trivial *Number comparison is non trivial ( -2 > -1 ) o One’s Complement *Left most bit represents the sign. *In order to negate, must flip all the bits. barb4right -x = flip_bits(x) * Can represent from –(2 N-1 -1) to 2 N-1 -1 Cons: * Still have two zeros. o Two’s Complement (standard) *Left most bit represents the sign. *In order to negate must flip bits and add 1. barb4right -x = flip_bits(x) +1 * Can represent from –2 N-1 to 2 N-1 -1 Unsigned numbers

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.

{[ 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