There are only 10 different kinds of people in the world:
those who know binary and those who don't.
- Anonymous
Computers are full of zillions of bits that are either on or off.
The way we talk about the value of a bit in the electical engineering and
computer science communities is first as a logical value (true
if on, false if off) and secondly as a
binary number
(1 if the bit is on and 0 if it's off). Most bits in a computer are
manipulated in groups, so we humans need a way to describe groups of bits,
things/objects a computer manipulates. Today, bits are most often
grouped in quantities of 8, 16, 32, and 64.
Think about how you write down sequential numbers starting with zero: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, etc... Our decimal number system has ten symbols. In this sequential series, when we ran out of symbols, we combined them. You learned how to do this so long ago, in grade school, that today you just naturally think in terms of single digit numbers, then tens, hundreds, thousands, etc... The decimal number 1234 is one thousand, two hundreds, three tens, and four units.
So, how does the binary number system used inside computers work?
Well, with only two symbols, we would write the same sequential numbers as above: 0, 1, 10, 11, 100, 101, 110, 111, 1000, 1001, 1010, 1011. The decimal number 1234 in binary is 10011010010.
Since even reasonable numbers that we use all the time make for very long binary numbers, the bits are grouped in 3s and 4s which are simple to convert into numbers in the octal and hexadecimal number systems. For octal, we group three bits together. Take the binary equivilent of decimal 1234, 10011010010, and put spaces in between each group of three bits - starting at the right and going left.
10011010010 = 10 011 010 010
Now use the symbols 0, 1, 2, 3, 4, 5, 6, and 7 (eight symbols, so OCTAL) to replace each group.
10 011 010 010 = 2 3 2 2 = 2322
The octal representations of the binary patterns are certainly easier to read, write, and remember than the binary counterparts. An even more compact representation can be achieved by grouping the bits in chunks of four and converting these to hexNumerals.
When you group four bits together and use sixteen symbols (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, A, B, C, D, E, and F) as their abbreviations, you have a hexadecimal representation.
10011010010 = 100 1101 0010 = 4D2
As you continue to explore how computers work, you'll hear more about numbers expressed in octal and hex; these are just more manageable representations of binary information - the digital world.
Table 1.2 compares the decimal, binary, octal, and hexadecimal number systems.
| Decimal Number |
in Binary |
in Octal |
in Hex |
1 |
1 |
1 |
1 |
2 |
10 |
2 |
2 |
3 |
11 |
3 |
3 |
4 |
100 |
4 |
4 |
5 |
101 |
5 |
5 |
6 |
110 |
6 |
6 |
7 |
111 |
7 |
7 |
8 |
1000 |
10 |
8 |
9 |
1001 |
11 |
9 |
10 |
1010 |
12 |
A |
11 |
1011 |
13 |
B |
12 |
1100 |
14 |
C |
13 |
1101 |
15 |
D |
14 |
1110 |
16 |
E |
15 |
1111 |
17 |
F |
16 |
10000 |
20 |
10 |
|
|
|||
So, if the most common groupings of bits in a computer are 8, 16, 32, and 64, what kinds of numbers can these groups represent?
A group of eight bits has binary values 00000000 through 11111111, or expressed in decimal 0 through 255. A group of sixteen bits has binary values 0000000000000000 through 1111111111111111, or decimal 0 through 65535. I'm not going to type in binary representations for groups of 32 and 64 bits. The range of decimal values for a group of 32 bits is 0 through 4,294,967,295. The range of decimal values for a group of 64 bits is 0 through 18,446,744,073,709,551,615 - or almost eighteen and a half quintillion.
But wait... these numbers are all positive (Whole Numbers). If we are going to allow for subtraction operations on numbers, which can result in negative numbers, we need Integers. Modern computers use one bit in each of the groups to represent the sign (positive or negative) when the groups are used to represent integers. Table 1.3 shows the range of numbers that can be represented with groups of 8, 16, 32, and 64 bits.
| Number of Bits |
Unsigned Maximum Value | Signed Minimum Value | Signed Maximum Value |
| 8 | 255 | -128 | 127 |
| 16 | 65535 | -32768 | 32767 |
| 32 | 4,294,967,295 | -2,147,483,648 | 2,147,483,647 |
| 64 | 18,446,744,073,709,551,615 | -9,223,372,036,854,775,808 | 9,223,372,036,854,775,807 |
| |
|||
That's about as deep as I want to get into the representation of numbers in computers and the binary, octal and hexadecimal number systems. Yes, computers have division operators but I am not going to cover numbers that include fractional parts, i.e., the "rational" and "irrational" numbers due to the complexity of their implementations. If you want to read more, I googled and found what looks like a good place for you to read more. Start at All About Circuits - Systems of numeration and read through it and continue on for a few more web pages in the series.
Ei kommentteja:
Lähetä kommentti