1 / 8

Negative Number

Negative Number. • Sign-Magnitude : left-most bit as the sign bit 16 bits Example: 4-bit numbers +5 10 is given by 0101 2 -5 10 is given by 1101 2 2’s complement: 16 bits: Example: 4-bit numbers + 5 10 is given by 0101 2’ -5 10 is given by 1011 2’. Lecture 9 notes.

Download Presentation

Negative Number

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Negative Number • Sign-Magnitude: left-most bit as the sign bit • 16 bits • Example: 4-bit numbers +510 is given by 01012 -510 is given by 11012 • 2’s complement: 16 bits: • Example: 4-bit numbers +510 is given by 01012’ -510 is given by 10112’

  2. Lecture 9 notes • Negative number • Sign-magnitude representation • 2’s complement • Binary addition • Binary subtraction

  3. Convert (156) 10 to (?) 2’ • 2’s complement representation of positive numbers is the same as sign-magnitude representation. • 16 bits example: • 156= 128 + 16 + 8 + 4 = 1* 27+ 1* 24 + 1* 23 + 1* 22 = (0000000010011100)2 = (0000000010011100)2’

  4. Convert (-156) 10 to (?) 2’ • Step 1: ignore the negative sign, obtain the 2’complement of the positive value: (156) 10 = (0000000010011100) • Step 2: Bitwise inverse: =(1111111101100011) 2 • Step 3: add 1 using binary addition =(1111111101100100) 2’ • done

  5. Remarks • Representation of negative number is always associated with the context of total bits • With 8 bits, -2 = (11111110) 2’ • With 16 bits, -2 = (1111111111111110) 2’

  6. Binary addition review sum bit carry bit Example:

  7. Binary Subtraction • When represented in sign-magnitude format, subtraction is performed in a similar way as in the base 10 case. • Subtraction uses a different set of `rules’ other than the addition • With 2’s complement representation, we can achieve subtraction via binary addition!

  8. Example 7-6 • Step 1: get 2’ complement representation for 7 and –6: 7 = (00000111) 2’ * -6=(11111010) 2’ ** • Perform binary addition between * and **, we get (1 00000001) • Ignore the overflow bit, we have (00000001) • Done, this is the result of the subtraction represented in 2’s complement format.

More Related