EE101Lecture4

EE101Lecture4 - Mark Redekopp, All rights reserved Lecture...

Info iconThis preview shows pages 1–6. Sign up to view the full content.

View Full Document Right Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Mark Redekopp, All rights reserved Lecture 4 Slides Sign Extension Overflow Binary Logic Mark Redekopp, All rights reserved 2s Complement Tricks Normal method of taking the 2s complement : Flip bits and add 1 Trick Start from LSB and work your way left towards MSB Copy bits through the first 1 you encounter Flip every bit after that 011010 Start from the LSB Copy bits through the first 1 Flip (invert) every bit after that 100110 011010 100101 + 1 100110 Normal 2s complement method 2s Complement Trick Mark Redekopp, All rights reserved Zero and Sign Extension Zero extension (unsigned) and Sign extension (2s comp.) is the process of increasing the number of bits used to represent a value without changing the value itself 2s complement = Sign Extension (Replicate sign bit): Unsigned = Zero Extension (Always add leading 0s): 111011 = 00 111011 011010 = 00 011010 110011 = 11 110011 pos. neg. Increase a 6-bit number to 8-bit number by zero extending Sign bit is just repeated as many times as necessary Mark Redekopp, All rights reserved Zero and Sign Truncation Zero truncation (unsigned) and Sign truncation (2s comp.) is the process of decreasing the number of bits used to represent a value without changing the value itself 2s complement = Sign Truncation (Remove copies of sign bit): Unsigned = Zero Truncation (Remove leading 0s): 00111011 = 111011 00 11010 = 011010 111 1 0011 = 10011 pos. neg. Decrease an 8-bit number to 6-bit number by truncating 0s. Cant remove a 1 because value is changed Any copies of the MSB can be removed without changing the numbers value. Be careful not to change the sign by cutting off ALL the sign bits. Mark Redekopp, All rights reserved Overflow Overflow occurs when the result of an arithmetic operation is too large to be represented with the given number of bits Unsigned overflow occurs when adding or subtracting unsigned numbers Signed (2s complement overflow) overflow occurs when adding or subtracting 2s complement numbers Mark Redekopp, All rights reserved...
View Full Document

Page1 / 21

EE101Lecture4 - Mark Redekopp, All rights reserved Lecture...

This preview shows document pages 1 - 6. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online