Integer
- Tags
- comp-arch
Is a primitive data-type for representing integer numbers.
Integers are normally stored as either words or pairs of words. One 64-bit machine word is the most common integer representation supporting \( 1.8446744 \times 10^{19} \).
Twos Complement
Is a common notation for representing negative values with integers. In this notation the left most bit is a sign bit. That is the value of that bit is negative when its a 1 and the remaining bits are positive and can be used to re-balance the integer. With twos complement if the first bit is a 1 then you can assume the value represented is negative.
Binary | Denary | Description |
---|---|---|
1000 | -8 | The left most bit is conventionally 8, in this case its \( -8 \). |
0111 | 7 | The left most bit is 0 so the number has no negative component. |
1111 | -1 | \( -8 + 4 + 2 + 1 = 7 \). |
0000 | 0 |
The range for an $n$-digit integer in twos-complement is \( -2^{n-1} \) to \( 2^{n-1} \).