tutorial2

tutorial2 - CS 230 Tutorial 2 January 17, 2011 Jonathan...

Info iconThis preview shows pages 1–31. 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

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

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

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

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: CS 230 Tutorial 2 January 17, 2011 Jonathan Rodriguez j2rodrig@uwaterloo.ca Binary Numbers and Arithmetic CS 230 Tutorial 2 2's Complement Numbers Examples of Binary Arithmetic Miscellaneous Items Word size, Execution speed 2's Complement 8-bit binary 00000000 00000001 00000010 00000011 00000100 00000101 decimal 1 2 3 4 5 2's Complement 8-bit binary 01111010 01111011 01111100 01111101 01111110 01111111 decimal 122 123 124 125 126 127 Sign bit 2's Complement 8-bit binary 01111111 10000000 decimal 127-128 Sign bit (1 means it's negative!) 2's Complement 8-bit binary 11111110 11111111 00000000 00000001 00000010 decimal-2-1 1 2-X = ~X + 1 Definition of 2's Complement: Complement (flip all bits) Addition (ex 1) 00010011 + 00000001 19 + 1 Addition (ex 1) 00010011 + 00000001 1 19 + 1 Carry Addition (ex 1) 00010011 + 00000001 1 19 + 1 20 Carry Addition (ex 1) 1 00010011 + 00000001 1 19 + 1 20 Addition 11 00010011 + 00000001 00 1 19 + 1 20 Addition (ex 1) 11 00010011 + 00000001 100 1 19 + 1 20 Addition (ex 1) 11 00010011 + 00000001 0100 1 19 + 1 20 Addition (ex 1) 11 00010011 + 00000001 10100 1 19 + 1 20 Addition (ex 1) 11 00010011 + 00000001 00010100 1 19 + 1 20 Addition (ex 2) 01011101 + 00010011 93 + 19 Addition (ex 2) 1 01011101 + 00010011 93 + 19 Addition (ex 2) 11 01011101 + 00010011 00 93 + 19 Addition (ex 2) 111 01011101 + 00010011 000 93 + 19 Addition (ex 2) 1111 01011101 + 00010011 0000 93 + 19 Addition (ex 2) 11111 01011101 + 00010011 10000 93 + 19 Addition (ex 2) 11111 01011101 + 00010011 110000 93 + 19 Addition (ex 2) 11111 01011101 + 00010011 01110000 93 + 19 Addition (ex 2) 11111 01011101 + 00010011 01110000 11 93 + 19 112 Addition (ex 3) 01100000 + 01100000 96 + 96 Addition (ex 3) 01100000 + 01100000 00000 96 + 96 Addition (ex 3) 1 01100000 + 01100000 000000 96 + 96 Addition (ex 3) 11 01100000 + 01100000 1000000 96 + 96 Addition (ex 3) 11 01100000 + 01100000 11000000 11 96 + 96 192 Addition (ex 3) 11 01100000 + 01100000 11000000 11 96 + 96 192 Overflow!...
View Full Document

Page1 / 77

tutorial2 - CS 230 Tutorial 2 January 17, 2011 Jonathan...

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

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