Documente Academic
Documente Profesional
Documente Cultură
– Binary
“There are 10 types of
– Octal
people, those who
– Decimal understand binary and
– BCD
those who don’t”
– Hexadecimal
For example:
843 = 8 x 102 + 4 x 101 + 3 x 100
= 8 x 100 + 4 x 10 + 3 x 1
= 800 + 40 + 3
For whole numbers, the rightmost digit position is the one’s position (100 = 1). The
numeral in that position indicates how many ones are present in the number.
The next position to the left is ten’s, then hundred’s, thousand’s, and so on. Each digit
position has a weight that is ten times the weight of the position to its right.
In the decimal number system, ten possible values can appear in each digit position,
The decimal numerals are the familiar zero through nine (0, 1, 2, 3, 4, 5, 6, 7, 8, 9).
In a positional notation system, the number base is called the radix. Thus, the base ten
system that we normally use has a radix of 10. Thus, in a case where the radix isn’t
understood, decimal numbers would be written like this:
In the binary number system, there are only two possible values (i.e. 0 and 1) that can
appear in each digit position rather than the ten that can appear in a decimal number.
Each digit position in a binary number represents a power of two. So, each binary digit
is multiplied by an appropriate power of 2 based on the position in the number:
For example:
101101 = 1 x 25 + 0 x 24 + 1 x 23 + 1 x 22 + 0 x 21 + 1 x 20
= 1 x 32 + 0 x 16 + 1 x 8 + 1 x 4 + 0 x 2 + 1 x 1
= 32 + 8 + 4 + 1
= 45
The term ‘bit’ is a contraction of the words ‘binary’ and ‘digit’, and the number in the
above example is a 6 bit number.
At each division, the remainder provides a digit of the converted number, starting with
the least significant digit.
18 / 2 = 9 remainder 0
9 / 2=4 remainder 1
4 / 2=2 remainder 0
2 / 2=1 remainder 0
46 / 2 = 23 remainder 0
23 / 2 = 11 remainder 1
11 / 2 = 5 remainder 1
5/2=2 remainder 1
2/2=1 remainder 0
For any number base greater than ten, a problem occurs because there are more than
ten symbols needed to represent the numerals for that number base.
It is customary in these cases to use the ten decimal numerals followed by the letters of
the alphabet beginning with A to provide the needed numerals.
Since the hexadecimal system is base 16, there are sixteen numerals required. The
following are the hexadecimal numerals:
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F
The reason for the common use of hexadecimal numbers is the relationship between
the numbers 2 and 16. Sixteen is a power of 2 (16 = 24).
Because of this relationship, four digits in a binary number can be represented with a
single hexadecimal digit. Hence, hexadecimal can be used to write large binary
numbers with much fewer digits.
Hexadecimal Numbers
By using hexadecimal, the numbers can be written with fewer digits and much less likelihood of
error.
To convert a binary number to hexadecimal, divide it into groups of four digits starting with the
rightmost digit.
If the number of digits isn’t a multiple of 4, prefix the number with 0’s so that each group contains
4 digits.
For each four digit group, convert the 4 bit binary number into an equivalent hexadecimal digit.
(See the Binary, BCD, and Hexadecimal Number Tables at the end of this Slide)
Divide into groups of 4 digits 0110 1011 1000 1100 Convert each
group to hex digit 6 B 8 C = 6B8C16
Hexadecimal to Binary Numbers
To convert a hexa-decimal number to a binary number, convert each hexadecimal digit into a
group of 4 binary digits.
Example: Convert the hex number 374F16 into binary
3 7 4 F
Convert the hex digits to binary 0011 0111 0100 1111
00110111010011112
TRY THIS. Convert the following hexadecimal numbers to their decimal equivalents:
(a) 2 4 3 F16
(b) B E E F16
TRY THIS: Convert the following decimal numbers to their hexadecimal equivalents:
(a) 6949810
(b) 11426710
Decimal to Hex
1 1 3 + E = 11
BA3 A + D = 17
+5 D E 17 + 1 (carry) = 18
---------------- B + 5 = 10
1181 10 + 1 (carry) = 11
1 1 1
A C 5 A 9 (9 + 4 = 13 < than 16 hence use ‘D’)
+ B D 6 9 4 (A + 9 = 19 > than OR =16 then 19 – 16 = 3 carry a 1)
--------------------- (1 + 5 + 6 = 12 < than 16 hence use ‘C’)
1 6 9 C 3 D (C + D = 25 > than OR =16 then 25 – 16 = 9 carry a 1)
(1 + A + B = 22 > than OR =16 then 22 – 16 = 6 carry a 1)
(1 + 0 + 0 = 1 < than 16 hence use ‘1’)
TRY:
1DEADDEAFBEEF
+ DADFED2BADBEE
-------------------------------------------
The Octal Number System
The same principles of positional number systems we applied to the decimal and binary
number systems can be applied to the octal number system.
However, the base of the octal number system is eight, so each position of the octal
number represents a successive power of eight.
From right to left, the successive positions of the octal number are weighted 1, 8, 64,
512, etc.
1 6 0 18
\ \ \_______________ 1 * 80 =1*1 =1
\ \__________________6 * 82 = 6 * 64 = 384
\___________________1 * 83 = 1 * 512 = 512
-------------------
89710
(1) Divide the decimal number by the base (in the case of octal, divide by 8).
(3) Continue dividing into each quotient (and indicating the remainder) until the divide
operation produces a zero quotient.
(4) The base 8 number is the numeric remainder reading from the last division to the first
(if you start at the bottom, the answer will read from top to bottom).
The Octal Number System
Example 1: Convert the decimal number 46510 to its octal equivalent:
465 / 8 = 58 remainder 1
58 / 8 = 7 remainder 2
7/8=0 remainder 7
Divide 8 into 465. The quotient is 58 with a remainder of 1; indicate the 1 on the right.
Divide 8 into 58 (the quotient from the previous division). The quotient is 7 with a remainder of 2,
indicated on the right.
Divide 8 into 7. The quotient is 0 with a remainder of 7, as indicated. Since the quotient is 0, stop
here.
The answer, reading the remainders from top to bottom, is 721, so 46510 = 7218
Binary to Octal / Octal to Binary
Binary to Octal
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.
Octal to Binary
Step 1 - Convert each octal digit to a 3 digit binary number (the octal digits may be
treated as decimal for this conversion).
Step 2 - Combine all the resulting binary groups into a single binary number.
318 / 8 = remainder 6
?/8=? remainder ?
?/8=? remainder ?
?/8=? remainder ?
TRY THIS: Convert the following decimal to octal and equivalent octal to binary:
(a) 300210
(b) 651210
Binary Addition
Binary Addition
Binary Addition
It is a key for binary subtraction, multiplication, division. There four rules of the binary
addition.
In fourth case, a binary addition is creating a sum of (1+1=10) i.e. 0 is write in the given
column and a carry of 1 over to the next column.
11 CARRY
0011010 = 2610
+ 0001100 = 1210
--------------------------------------------
0100110 = 3810
Binary Subtraction
Subtraction and Borrow, these two words will be used very frequently for the binary
subtraction. There are four rules of the binary subtration
01
01 BORROW
0011010 = 2610
- 0001100 = 1210
--------------------------------------------
0001110 = 1410
Binary Subtraction
Subtract 19 from 6.
0000 0110 6
−0001 0011 19
============== ====
11111 0011 −12 — An end-around borrow is produced, and the sign bit of
the intermediate result is 1.
−0000 0001 1 — Subtract the end-around borrow from the result.
============== ====
1111 0010 −13 — The correct result (6 − 19 = -13)
00010011 19
−11111100 −3
============== ====
10001 0111 23 — An end-around borrow is produced.
−0000 0001 1 — Subtract the end-around borrow from the result.
============== ====
0001 0110 22 — The correct result (19 − (−3) = 22).
COMPLIMENTS
Binary system complements
As the binary system has base radix, r = 2. So the two types of complements for the
binary system are 2's complement and 1's complement.
1's complement
The 1's complement of a number is found by changing all 1's to 0's and all 0's to 1's.
This is called as taking complement or 1's complement. Example of 1's Complement is
as follows.
2’s Compliment
The 2's complement of binary number is obtained by adding 1 to the Least Significant
Bit (LSB) of 1's complement of the number.
(a) 10110101
(b) 1010101010111111
Addition and Subtraction using 1's and 2's complement
Let's consider problem of subtracting 110 = 00012 from 710 = 01112 using 1's
complement.
To do this we change all the 1's to 0's and 0's to 1's. Notice that the most-significant digit
is now 1 since the number is negative. 0001 → 1110
Notice that our addition caused an overflow bit. Whenever we have an overflow bit in 1's
complement, we add this bit to our sum to get the correct answer. If there is no overflow
bit, then we leave the sum as it is.
0101
+ 1
-----------
0 1 1 0 (6) This gives us a final answer of 01102 (or 610).
Addition and Subtraction using 1's and 2's complement
Now let's look at problem that does not generate an overflow bit. We will subtract 710
from 110 using 1's complement. First, we state our problem in binary.
0001 (1)
-0111 - (7)
Next, we convert 01112 to its negative equivalent and add this to 00012.
0001 (1)
+1000 +(-7)
--------------------------
1001 (-6)
This time our results does not cause an overflow, so we do not need to adjust the sum.
Notice that our final answer is a negative number since it begins with a 1. Remember
that our answer is in 1's complement notation so the correct decimal value for our
answer is -610 and not 910.
Then discard the carry (indicates overflow), and you have your result: 0000 0010 which
equals to 2 as expected.
(a) 10 -8
(b) 11- 17
(c) 23 – 89
(d) 22 - 22
UNIT 1.5 : Number Systems
Powers of 2:
20 ......................1
21 ......................2
22 ......................4
23 ......................8
24 ....................16
25 ....................32
26 ....................64
27 ..................128
28 ..................256
29 ..................512
210 ................ 1024
211 ................ 2048
212 ................ 4096
213 ................ 8192
214 .............. 16384
215 .............. 32768
216 .............. 65536
UNIT 1.5 : Number Systems
Hexadecimal Digits
0 ...................... 0 0000
1 ...................... 1 0001
2 ...................... 2 0010
3 ...................... 3 0011
4 ...................... 4 0100
5 ...................... 5 0101
6 ...................... 6 0110
7 ...................... 7 0111
8 ...................... 8 1000
9 ...................... 9 1001
10 ..................... A 1010
11 ..................... B 1011
12 ..................... C 1100
13 ..................... D 1101
14 ..................... E 1110
15 ......................F 1111
Equivalent Numbers in Decimal, Binary and Hexadecimal Notation:
UNIT 1.5 : Number Systems
TRY THIS: Convert the following numbers to their decimal equivalents:
(a) 1 1 0 0 1 1 02
(b) 1 1 1 1 1 0 0 12
(c) 4910
(d) 2110
(e) 5 68
(f) 11638