|
|
|
|
|
|
|
Figure 1.12
Typical data types. |
|
|
|
|
|
|
|
|
1. Integers (signed or unsigned whole numbers). |
|
|
|
 |
|
|
|
|
Integers are the fundamental data type used in computers. Other numeric data types may be readily assembled using this data type.2 Different formats may be used to represent signed numbers, by far the most common of which is the two's-complement representation. This is the representation formed by using -a = 0 - a.3 The advantage of this format is that no special care need be taken with numbers after conversion (which does, however, require a subtraction) is complete. Less common is the one's-complement representation that is formed by -a = NOT a.4 This representation is much easier for converting between formats, but has several undesirable propertiesnot the least of which is that -0 does not have the same pattern as +0 (or unsigned 0 = +0). |
|
|
|
 |
|
 |
|
|
2Actually, bit strings form the basis for computer arithmetic. However, as bit strings do not provide any numeric functionality, their use as a basis for operations is fine for actual hardware (where everything is really a bit string), but complicates any practical discussion of arithmetic. |
|
|
|
 |
|
 |
|
|
3More formally, for an n bit binary number, -a = (2n - a) mod 2n, where 2n-1 > a |
|
|
|
 |
|
 |
|
|
4Or -a = (2n - 1 - a) mod (2n - 1). The dual representations of zero (all 1's or all 0's) occur because 0 º (2n - 1) mod (2n - 1). |
|
|
|
|
|