19.95
19 is 10011
.95
1 .9
1 .8
1 .6
1 .2
0 .4
0 .8
.95 is .111100
----
Try out this Java applet for adding. Be sure to use some numbers that overflow!
In twos-complement, the following two C++ statements are equivalent:
5 * 5 0101
0101
----
0101
0000
0101
0000
--------
00011001
5 * -5 0101
1011
----
0101
0101
0000
11011 -> note the negated sign !
--------
11100111
-5 * 5 1011
0101
----
11111011
0000
111011
0000
--------
11100111
-5 * -5 1011
1011
----
11111011
1111011
0000
0101
--------
00011001
By the way, some computers do not have a multiply instruction.