| Back
Binary
A computer operates on binary digits which use
a base 2 numbering system. To deter-mine the decimal
equivalent of a binary number each column is represented
by two raised to the power of 0, 1, 2, and so on.
For example, the decimal equivalents of 1000 0001
and 0101 0011 are:
|
2^7
|
2^6
|
2^5
|
2^4
|
2^3
|
2^2
|
2^1
|
2^0
|
|
| 128
|
64
|
32
|
16
|
8
|
4
|
2
|
1
|
Decimal
|
| 1
0 |
0
1 |
0
0 |
0
1 |
0
0 |
0
0 |
0
1 |
1
1 |
129
83 |
Thus 01010011 gives:
(0x128) + (1x64) + (0x32) + (1x16)+ (0x8) + (0x4)
+ (1x2) + (1x1) = 83
As seen the number of different representations
of the binary digits is determined by the number
of bits used to represent the value. With a single
binary digit we can represent two values (21), with
two binary digits we can represent four values (22),
and so on. For example:
- 8 bits gives 0 to 2^8-1 (255) different representations.
- 16 bits gives 0 to 2^16-1 (65,535) different representations.
- 32 bits gives 0 to 2^32-1 (4,294,967,295) different
representations.
Just as in the decimal system (with units, tens,
hundreds, and so on), the most-significant bit (msb)
is at the left-hand side of the binary number and
the least-significant bit (lsb) on the right-hand
side. To convert from decimal (base 10) to binary
the decimal value is divided by two recursively
and the remainder noted. The first remainder gives
the lsb and the last gives the msb. For example:
| 2
|
54
|
|
| |
27
|
r
0 <<< lsb |
| |
13
|
r
1 |
| |
6
|
r
1 |
| |
3
|
r
0 |
| |
1
|
r
1 |
| |
0
|
r
1 <<< msb |
Thus 54 in decimal is 110110 in binary. Normally
computer system use groups of 4 and 8 bits, thus
it is important to memorize some of the key values
for groups of 4 and 8, such as:
| Binary |
Decimal |
| 0000 |
0 |
| 1111 |
15 |
| 1111 1111 |
255 |
| 1111 1111 1111 |
4095 (4k) |
| 1111 1111 1111 1111 |
65,535 (64k) |
| 1111 1111 1111 1111 1111
1111 |
16,777,215 (16M) |
| 1111 1111 1111 1111 1111
1111 1111 1111 |
4,294,967,295 (4G) |
Typical groupings of bits are:
Nibble. A group of four bits. A nibble 16
(24) different combinations of ON/OFF, from 0000
to 1111.
Byte. A group of eight bits. A byte gives
256 (28) different combinations of ON/OFF, from
00000000 to 11111111.
Word. A group of 16 bits (2 bytes). A word
gives 65,536 (216) different combinations of ON/OFF,
from 0000000000000000 to 1111111111111111.
Long Word. A group of 32 bits (4 bytes).
A long word gives 4,294,967,296 (232) different
combinations of ON/OFF.
Back
Digital computers are digital systems, and
operate on binary information(base-2), that is,
0’s and 1’s. Unfortunately, humans have difficulties
in converting binary information into a decimal
format. Some of the operations within the computer
require that the user or programmer defines a binary
value. Typically requirements are:
To
specify a memory address. Typically
memory addresses in a computer are specified with
their binary address, thus there must be a
method to display this in a form which the user
can easily convert to and from.
To display or set
the value of a variable. Sometimes the actual
binary contents of a value needs to be interrogated
or set, thus there must be a form in which the user
can easily read and convert it into a binary form.
To specify network
addresses. A network address of a computer (such
as 146.176.151.140) often needs to be converted
into a form which the computer understands, thus
there must be a conversion between decimal and binary,
or vice versa.
These problems are solved by
either converting between binary and decimal,
or between binary and hexadecimal (base-16)
or octal (base-8). Without the aid of a calculator,
the conversion between binary and decimal is relatively
difficult for large binary numbers, but hexadecimal
and octal conversion make it easier, as they allow
the binary digits to be split into groups of four
(for hexadecimal) or three (for octal), and then
converted. Hexadecimal is the conversion most often
used to specify a memory address or in defining
the contents of a memory address.
Often it is difficult to differentiate
binary numbers from decimal numbers (as one
hundred and one can be seen as 101 in binary, and
vice-versa). A typical convention is to use a proceeding
b for binary numbers, for example 010101111010b
and 101111101010b are binary numbers. Hexadecimal
and octal are often used to represent binary
digits, as they are relatively easily to convert
to and from binary. Table 2 shows the basic conversion
between decimal, binary, octal and hexadecimal numbers.
A typical convention is to append a hexadecimal
value with an ‘h’ at the end (and octal number with
an o). For example, 43F1h is a hexadecimal value
whereas 4310o is octal.
To represent a binary digit
as a hexadecimal value, the binary digits are
split into groups of four bits (starting from the
least-significant bit). A hexadecimal equivalent
value then replaces each of the binary groups. For
example, to represent 0111 0101 1100 0000b the bits
are split into sections of four to give:
|
Binary |
0111 |
0101 |
1100 |
0000 |
|
Hex
|
7 |
5 |
C |
0 |
Thus, 75C0h represents the binary
number 0111010111000000b. To convert from
decimal to hexadecimal the decimal value is
divided by 16 recursively and each remainder noted.
The first remainder gives the least-significant
digit and the final remainder the most-significant
digit. For example, the following shows the hexadecimal
equivalent of the decimal number 1103:
|
16 |
1103 |
|
| |
68 |
r
F <<< lsd (least-significant
digit) |
| |
4 |
r
4 |
| |
0 |
r
4 <<< msd (most-significant
digit) |
Thus, the decimal value 1103
is equivalent to 044Fh.
Table 2: Decimal,
binary, octal and hexadecimal conversions
|
Decimal |
Binary |
Octal |
Hex
|
| 0
|
0000
|
0
|
0
|
| 1
|
0001
|
1
|
1
|
| 2
|
0010
|
2
|
2
|
| 3
|
0011
|
3
|
3
|
| 4
|
0100
|
4
|
4
|
| 5
|
0101
|
5
|
5
|
| 6
|
0110
|
6
|
6
|
|
7 |
0111
|
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
|
Back
The bit rate defines the speed at
which bits are transmitted, and is typically measured
as bits per second (bps). The faster the bits
are transmitted, the more data that can be sent.
Thus the bit rate relates directly to the bandwidth
of the system (that is, the amount of data which
can be transmitted). Typical units for bit rates
are bps, kbps (kilo-bps or 1000 bps), Mbps (mega-bps
or 1,000,000 bps) and Gbps (giga-bps or 1 billion
bps). On a calculator these units can be represented
in exponent format such as:
1 bps equates to 1E0
1 kbps equates to 1E+3
1 Mbps equates to 1E+6
1 Gbps equates to 1E+9
Thus 10Mbps in exponent format is
10E+6.
To convert to a bit timing (the
time for a single bit), the bit rate is inverted.
For example the bit timing for 1kbps will be 1
divided by 1E+3, which is 0.001s. This value is
difficult to interpret, thus it is also typically
converted into exponent format, such as 1E-3s.
Next we can convert this into fractions of units
of time, such as:
1E-3 is 1 milli-second or 1ms.
1E-6 is 1 micro-second or 1µs.
1E-9 is 1 nano-second or 1ns.
Thus there are 1000ms in a second,
and 1,000,000us in a second. The table below outlines
these.
| Bit
rate |
Time
for one bit (sec) |
T
(ms) |
T(µs) |
T(ns) |
| 1bps |
1 |
1000 |
1,000,000 |
1 billion |
| 10bps |
0.1 |
100 |
100,000 |
100 million |
| 100bps |
0.01 |
10 |
10,000 |
10 million |
| 1kbps |
0.001 |
1 |
1,000 |
1,000,000 |
| 10kbps |
0.000 1 |
0.1 |
100 |
100,000 |
| 100kbps |
0.000 01 |
0.01 |
10 |
10,000 |
| 1Mbps |
0.000 001 |
0.001 |
1 |
1000 |
| 10Mbps |
0.000 000 1 |
0.000 1 |
0.1 |
100 |
| 100Mbps |
0.000 000 01 |
0.000 01 |
0.01 |
10 |
| 1Gbps |
0.000 000 001 |
0.000 001 |
0.001 |
1 |
This can also be shown in exponent format, along
with convenient units for the bit timing, to give:
| Bit
rate |
Time
for one bit (sec) |
T
|
| 1bps |
1 |
1 s |
| 10bps |
100E-3 |
100ms |
| 100bps |
10E-3 |
10ms |
| 1kbps |
1E-3 |
1ms |
| 10kbps |
100E-6 |
100µs |
| 100kbps |
10E-6 |
10µs |
| 1Mbps |
1E-6 |
1µs |
| 10Mbps |
100E-9 |
100ns |
| 100Mbps |
10E-9 |
10ns |
| 1Gbps |
1E-9 |
1ns |
Back
|