8-bit unsigned unsigned char X ; /* in most C */ /* Not supported in Java 2^8 possibilities range 11111111 2^8-1 00000000 0 Examples of adding. Similar to grade school, there is a carry Overflow can occur 200+200 = 144 ??? What about negative numbers? char X ; /* in Java */ signed char X ; /* in C */ What did you do in grade school +0101010 is +42 -0101010 is -42 If the signs are the same... If the signs are the different.... Find the larger absolute value.... What if we could use the same rule for signed and unsigned 39 + -39 should be zero! 00100100 --> 36 + 11011011 --> -36 ????? [ones-complement] 11111111 OOPS (unless we want to call that -0) Let's add one to the bit-wise inverse 11011011 + 1 11011100 00100100 --> 36 + 11011100 --> -36 [twos-complement] 00000000 ZERO ! -Y is ~Y + 1 This really works in Java A-B is A + ~B + 1 Quaranteed! 00100100 --> 36 + 11011100 --> -36 [twos-complement] 1 00000000 ZERO ! But what about the one.... Don't worry about it for a minute. The weight of the msb is -2^7 2^8 possibilities range 01111111 2^7-1 10000000 -2^7 Mathematicians do not like the lack of simularity 100+100 = 72 01100100 + 01100100 11001000 ( or -128 + 64 + 8 == -56) You can add two numbers of the same sign and get the wrong result Adding two numbers of different signs is always OK What is -100 01100100 10011011 ones-complement (~) 10011100 twos-complement (~) 10011100 + 10011100 00111000 -100+-100 = 56 How to check --- well, look at the result [in hardware, check carry-in and carry-out on msb] Introduce the Full-Adder as a box Derive the truth table What is the Java statement for the carry-out?