1364 Number Systems (on CD) Appendix E Positional (Web domain)

1364 Number Systems (on CD) Appendix E Positional values: 25616 1 Symbol values: 177 and thus decimal 375 is equivalent to hexadecimal 177. E.6 Negative Binary Numbers: Two s Complement Notation The discussion in this appendix has been focussed on positive numbers. In this section, we explain how computers represent negative numbers using two s complement notation. First we explain how the two s complement of a binary number is formed, and then we show why it represents the negative value of the given binary number. Consider a machine with 32-bit integers. Suppose int value = 13; The 32-bit representation of valueis 00000000 00000000 00000000 00001101 To form the negative of value we first form its one s complement by applying Java s bit- wise complement operator (~): onesComplementOfValue = ~value; Internally, ~value is now value with each of its bits reversed ones become zeros and zeros become ones as follows: value: 00000000 00000000 00000000 00001101 ~value (i.e., value s ones complement): 11111111 11111111 11111111 11110010 To form the two s complement of value we simply add one to value s one s complement. Thus Two s complement of value: 11111111 11111111 11111111 11110011 Now if this is in fact equal to -13, we should be able to add it to binary 13 and obtain a result of 0. Let us try this: 00000000 00000000 00000000 00001101 +11111111 11111111 11111111 11110011 00000000 00000000 00000000 00000000 The carry bit coming out of the leftmost column is discarded and we indeed get zero as a result. If we add the one s complement of a number to the number, the result would be all 1s. The key to getting a result of all zeros is that the twos complement is 1 more than the one s complement. The addition of 1 causes each column to add to 0 with a carry of 1. The carry keeps moving leftward until it is discarded from the leftmost bit, and hence the resulting number is all zeros. Computers actually perform a subtraction such as x = a - value;
If you are searching for cheap webhost for your web application, please visit MySQL5 Web Hosting services.

Leave a Reply