APPENDIX D
Representing Negative Integers
The industry standard method for representing negative integers is called two’s complement. Here is how it works:
For an integer represented using 16 bits, the leftmost bit is reserved for the sign bit. If the sign bit is 0, then the integer is positive; if the sign bit is 1, then the integer is negative.
For example, let’s consider two numbers, one positive and one negative.
0000 0101 0111 1001 is a positive integer, which we call a.
1111 1111 1101 1010 is a negative integer, which we will call b.
Using the methodology presented in Chapter 1 for converting a binary number to a decimal number, we can convert the binary number, a, to its decimal equivalent. Hence, the value of a is calculated as follows: ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access