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.
As far as C/C++ or Java programming is concerned, the unsigned integer and 2s complement encodings are the most important since the There are two tables below that summarize these representations (or interpretations) using a 4-bit binary word. The first table emphasizes the point of view that we are looking at ways to interpret (or decode) binary words.
The second table emphasizes the point of view that we are looking at ways to represent (or encode) integers as binary words. Notice that the second table also shows us what part of the number line is encoded by each encoding. Each of the four methods represents a different segment of the number line.
With four bits, we have 16 different binary words to make use of, so we can represent (or, encode) at most 16 different integers, but not all of the encodings manage to represent this maximum number of integers.
|