get balance subtract 100 write balance ----------------------- balance 1000 process1 high priority process2 get balance subtract 100 get balance add 240 write balance (1240) write balance (900) -------------------------------------- binary addition a = 00111101 = 61 b = 00000111 = 4 + 2 + 1 = 7 convert 00111101 to dec 1x2^0 + 0x2^1 + 1x2^2 + 1x2^3 + 1x2^4 + 1x2^5 + 0x2^6 + 0x2^7 = 1x2^0 = 1 1x2^2 = 4 + 1x2^3 = 8 + 1x2^4 = 16 + 1x2^5 = 32 = 32 + 16 + 8 + 1 = 61 what is a + b? 0111111 a 00111101 b + 00000111 -------------- 01000100 convert 01000100 to decimal 0x2^0 + 0x2^1 + 1x2^2 + 0x2^3 + 0x2^4 + 0x2^5 + 1x2^6 + 0x2^7 = 2^6 + 2^2 = 64 + 4 = 68 -------------------------- suppose that we have -5 11111111 11111011 convert to positive 11111111 11111011 1's complement 00000000 00000100 +1 1 ------------------ 2's complement 00000000 00000101 conclude: this is -5 -------------------------- 11111111 11111011 = -5 shift right by 1 _1111111 11111101 what do we put in the left-most bit? if "normal" shift, we fill it in with a 0. for a signed number, copy the left-most bit from before to that position 11111111 11111101 = -3 arithmetic shift