Number Systems
103 |
102 |
101 |
100 |
1000 |
100 |
10 |
1 |
0 |
2 |
3 |
5 |
235 = 2 x 102 + 3 x 101 + 5 x 100
235 in the base 2 system
29 |
28 |
27 |
26 |
25 |
24 |
23 |
22 |
21 |
20
|
512 |
256 |
128 |
64 |
32 |
16 |
8 |
4 |
2 |
1 |
0 |
0 |
1 |
1 |
1 |
0 |
1 |
0 |
1 |
1 |
235 = 1 x 27 + 1 x 26 + 1 x 25
+ 0 x 24 + 1 x 23 + 0 x 22 + 1 x 21
+1 x 20
Therefore, in an 8-bit system, the representation of the base 10 number 235
would be
1 1 1 0 1 0 1 1
In a 16 bit system the representation would be 0 0 0 0 0 0 0 0 1 1 1 0 1 0 1
1
The reason computers use only the base 2 system for basic operations (as
opposed to some other more convenient to humans) is not theoretical. There
is no theoretical reason why some other base is not used. For example,
computers could use the standard base 10 system. One approach would be to
assign voltages to each of the numbers.
For example, 0 volts could represent 0, 5 volts could represent 1, etc. and
45 volts could represent the number 9.
The problem is one of stability and the resultant reliability. Over time,
voltages would begin to wander and result in errors in calculation. One the
other hand, the base 2 system - on or off - is the most stable and hence the
most reliable.
The Hexadecimal Reporting System
Humans have difficulty in thinking in the binary system, particularly if the
number is large. It is not natural to keep track of huge amounts of 0s and
1s. To simplify reporting, the computer frequently states information in the
hexadecimal system.
This system represents the decimal numbers 0 to 9 as 0 to 9. The numbers
from 10 to 15 are represented by the characters A to F.
Example
Bit Pattern |
Hexadecimal Representation |
0000 |
0 |
0001 |
1 |
0010 |
2 |
0011 |
3 |
0100 |
4 |
0101 |
5 |
0110 |
6 |
0111 |
7 |
1000 |
8 |
1001 |
9 |
1010 |
A |
1011 |
B |
1100 |
C |
1101 |
D |
1110 |
E |
1111 |
F |
This notation takes advantage of the fact that bit patterns within a machine
tend to have lengths in multiples of four. In particular, hexadecimal
notation uses a single tymbol to represent four bits, meaning that a string
of twelve bits can be represented by only three symbols.
For example, the 16 bit pattern
1010010011001000
can be represented as