Date: July 2, 2001
Author: Bob
bitzenbytes
Binary & Other Number Systems
The noumenal facts are that the title of this article existed
prior to the domain name that points to the website, and the domain name of the website
existed prior to your discovery of this article. The phenomenal facts are your
knowledge of the existence of the article and your estimated value of the article as it
exists in your mind.
Data Data of any sort must be converted from our understanding of it to
reproducible symbols. We record these symbols on media so that we can recall them at will.
Some of this media we can interpret directly with our senses. We also use machines to
record data. Some of these records can be interpreted directly with our senses, but some
of these records must be interpreted by machines before we can understand them. We call
these machines data processors. A computer is a data processor. The function of a computer
is to process data electronically inside a CPU and among other components. Data comes in
at least two flavors: analog and digital. Networks allow data to flow between computers;
Both analog and digital signals may be employed in communicating between computers.
Analog data Analog data typically occurs in wave form. Some analog data can be
interpreted by humans as sight and sound. The signals, which we send each other to
communicate, are data. Sound data has as many forms as sight data but we often don't
distinguish discreetly among sounds. Sound data may be transmitted as signals, speech, and
music. Sight data may include letters, numbers, and other characters (handwritten or
printed), as well as photos, graphics, and film. All these data are, in their nature, analog.
In this form, they are unusable in a computer. A computer can only process concise, simple
data formats; data such that it can be processed very effectively.
Digital data Computers, mostly, operate totally on electricity. Only electrical
data can be interpreted by a computer. Some newer computers also employ discreet light.
For simplicity, we will avoid light for the moment. Computers deal with data that can be
encoded using electric signals. While analog computers can be built (with multiple states
for a given datum object), the easiest form in which data can be encoded is as a series of
semaphores that indicate one of two states for each datum object. We call these states by
various names depending on the system of notation being used. Some example of the two
states would be the pairs: On/Off, Up/Down, 0/1, True/False, Positive/Negative, and so
forth. In a computer, these two states can be altered by a device called a switch. In a
computer, the most common switch used is a device called a transistor. With transistors we
can represent 0's and 1's, the two states of a unit in the binary number system. We call
these units by the name, bits.
When data is manipulated and transmitted by computers, the binary code that represents
the data can be encoded as either a digital signal or an analog signal, but the format of
the data is still digital, still binary.
Indeed, still 0 or 1. It will help, therefore, in
understanding the computer, if you limit your knowledge of numbers, for the moment, to 0,
1, many. The interpretation of data stored in a computer is challenging as it exists
in a virtual flatland in apprehension, where often a state of 0 is assumed until a state
of 1 is proven.
Bits, nibbles, and bytes Each 0 or 1, represented in a computer, is called a bit.
To move information from one place to another in a computer, or between computers, we take
collections of bits and transmit them over media. Bit is an abbreviation of the expression
BInary digiT. The digit is called binary because the values of the units
that it employs are derived from the binary number system. Collections of bits are
required to represent data and symbols that are more complex than bits. There are standard
collections of bits identified by the names: bit, nibble, byte, word, paragraph, segment,
and so forth. Sometimes these definitions vary from computer to computer.
Bits and bytes, however, tend to remain standard from computer to computer and the data
that we work with most is typically encoded in a byte. A bit is one binary digit and a
byte is 8 bits. A nibble is one half of a byte. Separated into two nibbles, a high order
nibble and a low order nibble, a byte can be represented as a sequential collection of two
nibbles.
Number Systems The numeric encoding of data for computers can be represented in
any of several number systems. The most common of these would be binary, octal, decimal,
and hexadecimal. The number system with which humans are most familiar is the decimal
number system (base 10.) Computers at the most basic level use the binary number system
(base 2). For brevity, clarity, and quick identification, we often use the hexadecimal
number system (base 16) to represent binary encoding. Most often, we find hexadecimal
notation useful for identifying short codes that identify one of a possible large number
of states. In our case, we will be examining and working with somewhat long strings of
hexadecimal numbers that represent addresses, binary masks used for filtering, and
identification codes.
Our Native Number System For our understanding, we would like to read numbers in
decimal. Because decimal is the number system that we learned as children and use most
often, we are most comfortable judging attributes of given numbers when those numbers are
represented in decimal notation--attributes like relative size, relative nearness,
relative value, and various mathematical relationships. Therefore, we feel most
comfortable when we have analyzed numbers, that employ a base other than 10, as decimal
numbers. It is easier for us to perform decimal math than the math required for numbers
using another base.
The Nibble: half of a byte... The concept of nibble, as one half of a byte is
important to this explanation because we will be using hexadecimal notation. Hexadecimal
notation has a unique relationship to binary notation and the concept of a nibble will be
important to rapid identification of bit patterns in a byte required for the understanding
of network addressing provided as hexadecimal notation. Beyond that we will have little
use for the concept of the nibble.
| bit |
0 |
1 bit |
| bit |
1 |
1 bit |
| nibble |
0110 |
4 bits |
| byte |
01101011 |
8 bits |
|
| Definitions of bits, nibbles and bytes |
The binary number system The binary number system has just two
digits as compared to the decimal system which has 10 digits. The decimal system
uses digits 0 through 9, the binary system only uses digits 0 and 1.
In the series of calculations below, we see how to build a decimal number based on the
value of the decimal digits contained in the number. In fact, we evaluate the magnitude of
each digit and then add the results together to form the decimal number. We do this all of
the time, but we fail to recognize it because we have done it so often that the process
seems to be "second nature" to us
| Unit Place |
|
7th |
6th |
5th |
4th |
3rd |
2nd |
1st |
|
| Unit Place Valuation |
|
106 |
105 |
104 |
103 |
102 |
101 |
100 |
|
Expanded valuation
X value of unit |
|
1000000
X 5 |
100000
X 2 |
10000
X 8 |
1000
X 2 |
100
X 3 |
10
X 4 |
1
X 9 |
|
|
|
|
|
|
|
|
|
|
|
| Valued unit (magnitude) |
|
5000000 + |
200000 + |
80000 + |
2000 + |
300+ |
40 + |
9 = |
5,282,349 |
Evaluation of the decimal (base 10) number 5,282,349
Units are generally represented by a single character. The possible values for units in
a base 10 system are represented by the characters, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9. There is
no rational reason to perform the series of conversions from base 10 to base 10, above. We
are, after all, converting a number of a given base to the same base. However, it does
show us the basic method for converting a number, that uses any basis, to decimal (base
10) for evaluation. We can make the same conversion from binary (base 2) to decimal (base
10) by evaluating the decimal value of binary digits in a given number. To do this we set
up the same series of calculations, substituting binary digits and base 2 unit place
valuation. The possible values for units in a base 2 system are 0 and 1.
| Unit Place |
8th |
7th |
6th |
5th |
4th |
3rd |
2nd |
1st |
|
| Unit Place Valuation |
27 |
26 |
25 |
24 |
2 3 |
22 |
21 |
20 |
|
Expanded valuation
X value of unit |
128
X 1 |
64
X 0 |
32
X 0 |
16
X 1 |
8
X 0 |
4
X 1 |
2
X 0 |
1
X 1 |
|
|
|
|
|
|
|
|
|
|
|
| Valued unit (magnitude) |
128 + |
0 + |
0 + |
16 + |
0 + |
4 + |
0 + |
1 = |
149 |
Evaluation of the binary (base 2) number, 10010101, as decimal number 149
The maximum value of a 7 digit decimal number would be 9,999,999. Similarly, the
maximum value for an 8 digit binary number would be 11111111. A byte holds 8 binary digits
and so the maximum value for a byte would be 255, decimal. Including the 0 value, all of
the possible values of a byte can be used to represent 256 states.
| Unit Place |
8th |
7th |
6th |
5th |
4th |
3rd |
2nd |
1st |
|
| Unit Place Valuation |
27 |
26 |
25 |
24 |
2 3 |
22 |
21 |
20 |
|
Expanded valuation
X value of unit |
128
X 1 |
64
X 1 |
32
X 1 |
16
X 1 |
8
X 1 |
4
X 1 |
2
X 1 |
1
X 1 |
|
|
|
|
|
|
|
|
|
|
|
| Valued unit (magnitude) |
128 + |
64 + |
32 + |
16 + |
8 + |
4 + |
2 + |
1 = |
255 |
Evaluation of the byte, base 2 number 11111111 as decimal number 255
A nibble holds 4 binary digits and the maximum value for a nibble would be 15, decimal.
Including the 0 value, all of the possible values of a nibble can be used to represent 16
states. Evaluate a byte as a high order nibble and a low order nibble and you can define
16 instances of 16 states or 256 possible states.
| Unit Place |
4th |
3rd |
2nd |
1st |
|
| Unit Place Valuation |
23 |
22 |
21 |
20 |
|
Expanded valuation
X value of unit |
8
X 1 |
4
X 1 |
2
X 1 |
1
X 1 |
|
|
|
|
|
|
|
| Valued unit (magnitude) |
8 + |
4 + |
2 + |
1 = |
15 |
Evaluation of the nibble, base 2 number 1111 as decimal number 15
However, most computers will not operate on a nibble as a value structure and so the
number of states that can be recognized in a nibble is not useful to us. The advantage of
recognizing the nibble, for us, is to use the high order and low order nibbles in a byte
to represent masked binary byte values (e.g., 10010101 represented as 10010000 and 00000101, or as 144 and 5,
yielding the value, 149, for the byte). Most computers will operate on a bit or a byte as
a value structure. These masked values can be rewritten in hexadecimal notation, a useful
exercise as it will reveal the unique relationship of hexadecimal to binary. In this case
10010000 is equivalent to 90h
and 00000101 is equivalent to 05h.
Add these masked values and we have 95h which converts to the decimal value of 149.
In other words, two digit hexadecimal values represent not only the precise value of a
binary representation of a byte, but they also reveal the exact bit pattern of a byte by
simple inspection. Variables in high level programming languages may use larger structures
than bytes such as words or long words to represent very large values. Typically, these
are always defined in byte sized increments. Hence, the use of hexadecimal notation to
represent byte values and bit patterns and the recognition of the nibble remains useful to
us as a powerful mnemonic.
In review, hexadecimal notation calls for 16 single character digits to represent
possible values of a hexadecimal unit. These represent the values 0 through 15 in decimal,
the exact values that we can represent with a nibble. Creating a conversion table of the
numbers in all three bases shows the relationship.
| 16 Unit Number System Conversion Table |
| Decimal |
Binary |
Hexadecimal |
| 15 |
1111 |
F |
| 14 |
1110 |
E |
| 13 |
1101 |
D |
| 12 |
1100 |
C |
| 11 |
1011 |
B |
| 10 |
1010 |
A |
| 9 |
1001 |
9 |
| 8 |
1000 |
8 |
| 7 |
0111 |
7 |
| 6 |
0110 |
6 |
| 5 |
0101 |
5 |
| 4 |
0100 |
4 |
| 3 |
0011 |
3 |
| 2 |
0010 |
2 |
| 1 |
0001 |
1 |
| 0 |
0000 |
0 |
From this table, it can be discovered that the decimal value of 14 can be represented in
binary notation by the nibble, 1110, and that nibble can be represented by the hexadecimal
notation, E (usually written Eh.). That is straight forward. However, there is yet another
relationship we know to discover. We find that representation of the possible values of a
byte, in hexadecimal notation, shows that not only does a double digit hexadecimal value
represent a byte value, but that the two hexadecimal values also exactly represent the bit
pattern for the high and low order nibbles of a byte.
For example, the hexadecimal number F4h converts to the decimal value of 244. 244 can
be represented in binary notation by the byte having a bit pattern of 11110100. Separating
the high and low order nibbles we find that 1111 has the value of Fh and 0100 has the
value of 4h. Therefore we can represent the bit pattern of a byte with a double digit
hexadecimal number confident that the value of the hexadecimal number is the same value
represented by the binary bit pattern in the byte.
Be clear that this has nothing to do with the nibble as a value structure. Double-digit
hexadecimal notation is simply a useful shorthand for preserving both the value and the
bit pattern of a byte in a manner that lets both be easily reconstructed while utilizing a
notation format that makes identification of specific bytes and/or bit patterns easier to
locate and identify in a long listing.
These facts are not only helpful for network addresses and subnetting, but will also be
useful for interpretation of frame or packet values displayed by network monitors. |