IntegerArithmetic

# IntegerArithmetic - Integer Arithmetic operations we'll get...

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

Integer Arithmetic operations we'll get to know (and love): addition subtraction multiplication division logical operations (not, and, or, nand, nor, xor, xnor) shifting the rules for doing the arithmetic operations vary depending on what representation is implied. A LITTLE BIT ON ADDING ---------------------- an overview. carry in a b | sum carry out ---------------+---------------- 0 0 0 | 0 0 0 0 1 | 1 0 0 1 0 | 1 0 0 1 1 | 0 1 1 0 0 | 1 0 1 0 1 | 0 1 1 1 0 | 0 1 1 1 1 | 1 1 | a 0011 +b +0001 -- ----- sum 0100 its really just like we do for decimal! 0 + 0 = 0 1 + 0 = 1 1 + 1 = 2 which is 10 in binary, sum is 0 and carry the 1. 1 + 1 + 1 = 3 sum is 1, and carry a 1.

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

View Full Document
ADDITION unsigned: just like the simple addition given. examples: 100001 00001010 (10) +011101 +00001110 (14) ------- --------- 111110 00011000 (24) ignore (throw away) carry out of the msb. Why? Because computers ALWAYS work with a fixed precision. sign magnitude: rules: - add magnitudes only (do not carry into the sign bit) - throw away any carry out of the msb of the magnitude (Due, again, to the fixed precision constraints.) - add only integers of like sign ( + to + or - to -) - sign of result is same as sign of the addends examples: 0 0101 (5) 1 1010 (-10) + 0 0011 (3) + 1 0011 (-3) --------- --------- 0 1000 (8) 1 1101 (-13) 0
This is the end of the preview. Sign up to access the rest of the document.

## This note was uploaded on 11/04/2009 for the course CS 333 taught by Professor Stankovic during the Fall '08 term at UVA.

### Page1 / 6

IntegerArithmetic - Integer Arithmetic operations we'll get...

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

View Full Document
Ask a homework question - tutors are online