Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Inbound 3076236495533383827

Download as pdf or txt
Download as pdf or txt
You are on page 1of 67

Digital systems do not store numbers the

way humans do. A human can remember the


number 4.5 and understand that it represents
a quantity. The digital system does not have
this capability. Instead, digital systems work
with numbers using millions of tiny switches
called transistors. Each transistor can
remember only one of two possible values,
on or off. This is referred to as a binary
system.
The values represented by the
transistors of a binary system can be
interpreted as needed by the
application. On and off can just as
easily mean 1 or 0, yes or no, true or
false, up or down, or high or low. At this
point, it is immaterial what the two
values represent.
Why Binary?

The number system that you are


familiar with, that you use every day, is
the decimal number system, also
commonly referred to as the base-10
system. When you perform
computations such as 3 + 2 = 5, or 21 –
7 = 14, you are using the decimal
number system.
Why Binary?
This system, which you likely learned in
first or second grade, is ingrained into
your subconscious; it’s the natural way
that you think about numbers. Of course
it is not just you: It is the way that
everyone thinks—and has always
thought—about numbers and
arithmetic. Evidence exists that
Egyptians were using a decimal number
system five thousand years ago.
Why Binary?
The Roman numeral system, predominant
for hundreds of years, was also a decimal
number system (though organized
differently from the Arabic base-10 number
system that we are most familiar with).
Indeed, base-10 systems, in one form or
another, have been the most widely used
number systems ever since civilization
started counting.
Why Binary?
In dealing with the inner workings of a computer,
though, you are going to have to learn to think in a
different number system, the binary number system,
also referred to as the base-2 system.

Before considering why we might want to use a


different number system, let’s first consider: Why do
we use base-10? The simple answer: We have 10
fingers. Before the days of calculators and computers,
we counted on our hands (many of us still do!).
Why Binary?
There is nothing essentially “easier” about using the
base-10 system. It just seems more intuitive only
because it is the only system that you have used
extensively, and, again, the fact that it is used
extensively is due to the fact that humans have 10
fingers. If humans had six fingers, we would all be
using a base-6 system, and we would all find that
system to be the most intuitive and natural.

So, long ago, humans looked at their hands, saw ten


fingers, and decided to use a base-10 system.
Why Binary?

This is considered as the computer


machine language. It means that on the
machine level, this is the only
recognizable data to the computer. The
binary simulates the toggle switches that
a computer uses to perform its
calculations. It has a base or radix of 2.
Counting with the Binary and Decimal
Number Systems
Binary Decimal
0 0
1 1
10 2
11 3
100 4
101 5
110 6
111 7
1000 8
1001 9
1010 10
1011 11
Example
Binary Number : 110112
Calculating Decimal Equivalent:
Step Binary Decimal
Number Number
Step 1: 11011 = ((1 x 24) + (1x 23) + (0 x 22) + (1 x 21) + (1 x 20)) 10
Step 2: 11011 = 16 + 8 + 0 + 2 + 1
Step 3: 11011 = 27 10

Note : 11011 is normally written as 110112


Convert 110112 to
Decimal

10
Example:

1.) 1101012 7.) 10010012


2.) 1001112 8.) 1001012
3.) 111012 9.) 1011102
4.) 10111012 10.) 1110112
5.) 1110012
6.) 1011012
Steps: Decimal to Binary
Step 1 − Divide the decimal number to be converted by the value of
the new base.
Step 2 − Get the remainder from Step 1 as the rightmost digit least
significant digit of new base
number.
Step 3 − Divide the quotient of the previous divide by the new base.
Step 4 − Record the remainder from Step 3 as the next digit to the
left of the new base
number.
Repeat Steps 3 and 4, getting remainders
from right to left, until the quotient becomes
zero in Step 3.
The last remainder thus obtained will be the
Most Significant Digit MSD of the new base
number.
Example 1:
Decimal to Binary
1.) Decimal Number: 2910

Step Operation Result Remainder


Step 1: 29 / 2 = 14 1 LSD
Step 2: 14 / 2 = 7 0
Step 3: 7 / 2 = 3 1
Step 4: 3 / 2 = 1 1
Step 5: 1 / 2 = 1 1 MSD
0

2910 = 0111012 or 111012


As mentioned in Steps 2 and 4, the
remainders have to be arranged in the
reverse order so that the first remainder
becomes the Least Significant Digit LSD and
the last remainder becomes the Most
Significant Digit MSD.

2910 = 111012
Example 2:
Examples: Decimal to Binary

1.) 15610 2.) 10910 3.) 31510

4.) 29510 5.) 17610


Addition of multi-bit binary numbers is
accomplished using the results, on a column-
by-column basis. That is, for each column,
use the results:
0+0=0
1+0=1
1 + 1 = 0 with a carry of 1 to the left
1 + 1 + 1 = 1 with a carry of 1 to the left
Example: Addition of the binary
numbers:
1.) 01 3.) 111
+ 11 + 10

2.) 1 0 1 4.) 110


+1 1 +01
Just as with addition, we're going to use
the decimal numbering system to
illustrate the process used in the binary
numbering system for subtraction.
The rules for binary subtraction are:
0–0 =0
1–0 =1
1–1 =0
0–1 = 1 (with a borrow of 1)
For example:

1001
-111
-------------
0010
Example:

1.)1 1 0 1 2.) 1 1 1 0 1 3.) 1 0 1 0


- 111 - 1110 - 110
110 1111 100
Binary multiplication is similar to decimal multiplication. It is simpler than
decimal multiplication because only 0s and 1s are involved. There are four
rules of binary multiplication.
Example:
1.) 1 0 1 1 2.) 1 0 0 1
x 10 x 11

3.) 1 1 0 1 4.) 1 1 1 0
x 100 x110
Octal system used to be widespread back
when many computers used 6-bit bytes, as
a 6-bit byte can be conveniently written as
a two-digit octal number. Since nowadays a
byte is almost always 8-bits long the octal
system lost most of its appeal to the
hexadecimal system.
Octal to Decimal
Example 1:
Example 2:
Binary to Octal
To convert a binary integer to octal, each three-bit
cluster corresponds to a single octal digit. If the
number of bits in the binary integer is not a multiple
of three, add zeros to the left, e.g., 11011 = 011011.
There are spaces between to separate the three-bit
clusters in the numbers below so you can see the
correspondence with the octal-digits.
Steps:
Step 1 − Divide the binary digits
into groups of three starting from
the right.
Step 2 − Convert each group of
three binary digits to one octal
digit.
Table: Binary to Octal
Binary
Octal
Example:
Binary Number − 101012
Calculating Octal Equivalent

Step Binary Number Octal Number


Step 1 101012 010 101
Step 2 101012 28 58
Step 3 101012 258

Binary Number − 101012 = Octal Number − 258


Octal to binary
Example:
1.) 3468 – 011 100 110
- 111001102
2.) 1578 – 001 101 111
- 11011112
Hexadecimal Representation
The word hexadecimal combines the Greek
hexa for six with the English word decimal.
"Hexadecimal" is too long to say all the time
so we usually just say hex . We need 16 hex-
digits to represent integers in base 16. We
use the ordinary decimal digits 0; : : : ; 9 and
the letters A, B, C, D, E, and F (or a, b, c, d,
e, and f) to represent 10, 11, 12, 13, 14, and
15 respectively.
Table Hexadecimal:
The binary representations of numbers
can be quite long and difficult for
humans to read. Hexadecimal
numbers are particularly useful for
representing patterns of binary values
(bitmasks), machine addresses, or any
particular bytes or words. Each hex-
digit corresponds to four bits which is
half a byte or a nibble.
Binary to Hexadecimal
Steps:

Step 1 - Divide the binary digits into


groups of four (starting from the right).
Step 2 - Convert each group of four
binary digits to one hexadecimal symbol.
Example:
1.) 100010112 = 1000 1011 = 8B16
2.) 1110011011012 = 1110 0110 11012 = E6D16

3.) 1100111011102 = 1100 1110 11102 = CEE16


Hexadecimal to Binary
Steps:

Step 1 - Convert each hexadecimal digit to a 4 digit


binary number (the hexadecimal digits may be
treated as decimal for this conversion).
Step 2 - Combine all the resulting binary groups (of
4 digits each) into a single binary number.
Example:
1.) 72316 = 0111 0010 00112 =111001000112

2.) 84A16 =1000 0100 10102 =1000010010102


3.) B6E16 =1011 0110 11102 =1011011011102
Hexadecimal to Decimal
Example:

1) A216 = 2x160 = 2
10x161 = 160
16210
2.) 13BC16 = 12x160 = 12
11x161 = 76
3x162 = 768
1x163 = 4096
505210
Hexadecimal numbers (base 16) can be
added using the same method. The
difference is that there are more digits in
hexadecimal than there are in decimal. For
example, in decimal, adding 5 and 7 results
in 2 with a carry to the next highest
position. In hexadecimal, however, 5 added
to 7 does not go beyond the range of a
single digit. In this case, 5 + 7 = C16 with no
carry. It isn't until a result greater than F16 is
reached (a decimal 1510) that a carry is
necessary.
In decimal, if the result of an addition
is greater than 9, subtract 1010 to get
the result for the current column and
add a carry to the next column. In
hexadecimal addition, if the result is
greater than F16 (1510) subtract 1016
(1610) to get the result for the current
column and add a carry to the next
column.
D16 + 516 = 1310 + 510 = 1810

By moving a carry to the next highest


column, we change the result for the
current column by subtracting 1610.
1810 = 210 + 1610
= 216 with a carry to the next
column

Therefore, D16 added to 516 equals


216 with a carry to the next column.
Hexadecimal to Decimal
Conversion Table
Example:
Add 3DA3216 to 4292F16.

Solution:
Just like in binary and decimal, place one of the
numbers to be added on top of the other so that
the columns line up.
For the next column, the 161 position, we have
1 + 3 + 2 which equals 6. This result is less
than 1610, so there is no carry to the next
column.
The 162 position has A16 + 916 which in
decimal is equivalent to 1010 + 910 = 1910.
Since this is greater than 1610, we must
subtract 1610 to get the result for the 162
column and add a carry in the 163
column.
For the 163 column, we have 116 + D16 +
216 which is equivalent to 110 + 1310 + 210 =
1610. This gives us a zero for the result in
the 163 column with a carry.
Last of all, 1 + 3 + 4 = 8 which is the same
in both decimal and hexadecimal, so the
result is 3DA3216 + 4292F16 = 8036116:
Hexadecimal Subtraction
The subtraction of hexadecimal numbers
follow the same rules as the subtraction of
numbers in any other number system. The
only variation is in borrowed number. In the
decimal system, you borrow a group of 1010.
In the binary system, you borrow a group of
210. In the hexadecimal system you borrow a
group of 1610.
Example:

You might also like