In class we have covered four different ways to represent integers using binary words. (or, another way to put this, we have learned four different ways to encode integers into binary words). Still another way to say this is that we have learned four different ways to interpret binary words as integers (or, we have learned four different ways to decode binary words into integers). The four different representations (i.e., encodings) of integers (or, the four different interpretations (i.e., decodings) of binary words) are called unsigned integer, signed magnitude, 2s complement, and biased. There are two tables below that summarize these representations (or interpretations). The first table emphasizes the point of view that we are looking at ways to represent (or encode) integers as binary words. The second table emphasizes the point of view that we are looking at ways to interpret (or decode) binary words. The tables use a 4-bit binary word.
With four bits, we have 16 different binary words to make use of, so we can represent (or, encode) at most 16 different integers (not all of the encodings manage to represent this maximum number of integers). Notice that each of the four methods represents a different segment of the number line.
It is worth remarking that, as far as C/C++ programming is concerned, the unsigned integer and 2s complement methods are the most important since the
|