Introduction
Number Systems
Types of Number systems
Inter conversion of number systems
Binary addition ,subtraction, multiplication and
division
Complements of binary number(1’s and 2’s
complement)
Grey code, ASCII, Ex
3,BCD
2. Module 1 objective
Introduction
Number Systems
Types of Number systems
Inter conversion of number systems
Binary addition ,subtraction, multiplication and
division
Complements of binary number(1’s and 2’s
complement)
Grey code, ASCII, Ex-3,BCD
3. Radix of a number systems
Binary
Decimal
Hexadecimal
Octal
BCD , EBCD, Excess 3
4. Number system and representation
Roman number system
1 5 10 50 100 500 1000
I V X L C D M
1 2 3 4 5 6 7 8 9
I II III IV V VI VII VIII IX
Example 2012 to be represented in roman
MMXII
10 20 30 40 50 60 70 80 90
X XX XXX XL L LX LXX LXXX XC
Solve 3023
MMMXXIII
5. Radix of number system
Binary (radix=2): 1000111101 (radix=2)
Ternary (radix=3) : 0 to 3
Octal (radix=8): 0 to 7
Decimal (radix=10): 0 to 9
Hexadecimal (radix=16) : 0 to 9 and A,B,C,D,E,F
BCD, EBCD, Excess3,BCO(coded octal),BCH(hexa)
Binary ,octal , decimal and hexadecimal are called positional number
system
6. Computers store and process data in terms of binary numbers.
Binary numbers consist of only the digits 1 and 0.
It is important for Computer Scientists and Computer Engineers to
understand how binary numbers work.
6Note: “Binary Numbers” are also referred to as “Base 2” numbers.
Binary Numbers
7. You probably learned about placeholders in the 2nd or 3rd grade. For
example:
7
3125
1’s place10’s place100’s place1000’s place
So this number represents
• 3 thousands
• 1 hundred
• 2 tens
• 5 ones
Mathematically, this is
(3 x 1000) + (1 x 100) + (2 x 10) + (5 x 1)
= 3000 + 100 + 20 + 5 = 3125
But why are the placeholders 1, 10, 100, 1000, and so on?
Review of Placeholders
8. The numbers commonly used by most people are in Base
10.
The Base of a number determines the values of its
placeholders.
8
312510
100 place101 place102 place103 place
To avoid ambiguity, we often write the base of a number as a subscript.
More on Placeholders
9. 9
20 place21 place22 place23 place
10102
This subscript denotes that this number is in Base 2 or “Binary”.
1’s place2’s place4’s place8’s place
Binary Numbers - Example
10. 10
10102
1’s place2’s place4’s place8’s place
So this number represents
• 1 eight
• 0 fours
• 1 two
• 0 ones
Mathematically, this is
(1 x 8) + (0 x 4) + (1 x 2) + (0 x 1)
= 8 + 0 + 2 + 0 = 1010
Binary Numbers - Example
11. 11
Base 10
0
1
2
3
4
5
6
7
8
9
10
Base 2
0
1
10
10digits
2digits
Base 16
0
1
2
3
4
5
6
7
8
9
A
B
C
D
E
F
10
16digits
Note: Base 16 is also called “Hexadecimal” or “Hex”.
Base 16
Cheat Sheet
A16 = 1010
B16 = 1110
C16 = 1210
D16 = 1310
E16 = 1410
F16 = 1510
Add Placeholder
Add Placeholder
Add Placeholder
Which Digits Are Available in which Bases
12. 12
160 place161 place162 place
3AB16
This subscript denotes that this number is in Base 16 or “Hexadecimal” or “Hex”.
1’s place16’s place256’s place
Note:
162 = 256
Hexadecimal Numbers - Example
13. 13
3AB16
1’s place16’s place256’s place
So this number represents
• 3 two-hundred fifty-sixes
• 10 sixteens
• 11 ones
Base 16
Cheat Sheet
A16 = 1010
B16 = 1110
C16 = 1210
D16 = 1310
E16 = 1410
F16 = 1510
Mathematically, this is
(3 x 256) + (10 x 16) + (11 x 1)
= 768 + 160 + 11 = 93910
Hexadecimal Numbers - Example
14. 14
What is the largest
number you can
represent using four
binary digits?
_ _ _ _2
1 1 1 1
23 22 21 20
8 4 2 1
=
=
=
=
8 + 4 + 2 + 1 = 1510
… the smallest
number?
_ _ _ _2
0 0 0 0
23 22 21 20
0 + 0 + 0 + 0 = 010
What is the largest
number you can
represent using a
single hexadecimal
digit?
Base 16
Cheat Sheet
A16 = 1010
B16 = 1110
C16 = 1210
D16 = 1310
E16 = 1410
F16 = 1510
_16
F = 1510
… the smallest
number?
_16
0 = 010 Note: You can represent the
same range of values with a
single hexadecimal digit that
you can represent using four
binary digits!
Why Hexadecimal Is Important
15. 15
It can take a lot of
digits to represent
numbers in binary.
Example:
5179410 = 11001010010100102
Long strings of digits
can be difficult to
work with or look at.
Also, being only 1’s
and 0’s, it becomes
easy to insert or
delete a digit when
copying by hand.
Hexadecimal
numbers can be
used to abbreviate
binary numbers.
Starting at the least
significant digit, split
your binary number
into groups of four
digits.
Convert each group
of four binary digits
to a single hex digit.
Why Hexadecimal Is Important Continued
16. 16
Recall the example binary number from the previous slide:
11001010010100102
1100 1010 0101 00102
First, split the
binary number
into groups of
four digits,
starting with the
least significant
digit.
Next, convert
each group of
four binary digits
to a single hex
digit.
C A 5 2
Base 16
Cheat Sheet
A16 = 1010
B16 = 1110
C16 = 1210
D16 = 1310
E16 = 1410
F16 = 1510
Put the single
hex digits
together in the
order in which
they were found,
and you’re done!
16
Converting Binary Numbers to Hex
17. 17
In many situations, instead of using a subscript
to denote that a number is in hexadecimal, a
“0x” is appended to the front of the number.
Look! Hexadecimal Numbers!
Windows
“Blue Screen of Death”
18. 1
8
Example:
We want to convert 12510 to hex.
125 / 16 = 7 R 13
7 / 16 = 0 R 7
12510 = 7D16
Base 16
Cheat Sheet
A16 = 1010
B16 = 1110
C16 = 1210
D16 = 1310
E16 = 1410
F16 = 1510
Converting Decimal to Hex
20. Decimal to binary
41.68755 radix 10 for fractional number
101001
q r
2 41 1
2 20 0
2 10 0
2 5 1
2 2 0
2 1 1
2 0
0.68755 x2=1.3750
0.3750x2=0.7500
0.7500x2=1.5000
0.5000x2=1.0000
1011
41.68755=101001.1011
Note : conversion from integer to any base –r system similar
to the above example only 2 will replaced by r
21. Decimal to binary
41.68755 radix 10 for fractional number Example
101001
q r
2 41 1
2 20 0
2 10 0
2 5 1
2 2 0
2 1 1
2 0
0.68755 x2=1.3750
0.3750x2=0.7500
0.7500x2=1.5000
0.5000x2=1.0000
1011
41.68755=101001.1011
22. Decimal to Octal
153.153 radix 10 for fractional number to octal
231
0.153 x8=4.104
0.104x8=0.832
0.832x8=6.656
0.656x8=5.248
0.248x8=1.984
0.984x8=7.872
0.406517
153.153=231.406517
q r
8 19 1
8 2 3
8 0 2
23. Decimal to Octal
153.153 radix 10 for fractional number to octal example
231
0.153 x8=4.104
0.104x8=0.832
0.832x8=6.656
0.656x8=5.248
0.248x8=1.984
0.984x8=7.872
0.406517
153.153=231.406517
q r
8 19 1
8 2 3
8 0 2
24. Decimal to Hexadecimal
253 radix 10 for fractional number to Hexadecimal example
FD 253=FD
q r
16 253 13(D)
16 15 15(F)
25. Binary to decimal
101101 to decimal
(101101)2 =25 x 1+24 x0 +23 x1 +22 x 1 +21 x 1+20 x 1
(1011014)2 = 32+8+4+1=4510
B
26. The computer systems accept the data in decimal form,
whereas they store and process the data in binary form.
Therefore, it becomes necessary to convert the numbers
represented in one system into the numbers represented in
another system. The different types of number system
conversions can be divided into the following major
categories:
• Non-decimal to decimal
• Decimal to non-decimal
• Octal to hexadecimal
Conversion of Numbers
27. The non-decimal to decimal conversions can be
implemented by taking the concept of place values into
consideration. The non-decimal to decimal conversion
includes the following number system conversions:
• Binary to decimal conversion
• Hexadecimal to decimal conversion
• Octal to decimal conversion
Non-Decimal to Decimal
28. A binary number can be converted to equivalent decimal
number by calculating the sum of the products of each
bit multiplied by its corresponding place value.
Examples 6.14 and 6.17, p110.
6.14: Convert the binary number 10101101 into its
corresponding decimal number.
(127)+(026)+(125)+(024)+(123)+(122)+ (021)+(120)
=128+0+32+0+8+4+0+1
=173
Non-Decimal to Decimal
29. A hexadecimal number can be converted into its
equivalent number in decimal system by calculating the
sum of the products of each symbol multiplied by its
corresponding place value.
Examples 6.20 and 6.22, p111.
6.20: Convert the hexadecimal number 6B39 into its
equivalent in the decimal system.
(6163)+(11162)+(3161)+(9160)
=24567+2816+48+9
=27449
Hexadecimal to Decimal Conversion
30. An octal number can be converted into its
equivalent number in decimal system by
calculating the sum of the products of each digit
multiplied by its corresponding place value.
Examples 6.25 and 6.28, p113.
6.25: Convert the octal number 13256 into its
equivalent in decimal systems.
(184)+(383)+(282)+(581)+(680)
=4096+1536+128+40+6
=5806
Octal to Decimal Conversion
31. The decimal to non-decimal conversions are carried out
by continually dividing the decimal number by the base
of the desired number system till the decimal number
becomes zero. After the decimal number becomes zero,
we may note down the remainders calculated at each
successive division from last to first to obtain the
decimal number into the desired system. The decimal to
non-decimal conversion includes the following number
system conversions:
• Decimal to binary conversion
• Decimal to hexadecimal conversion
• Decimal to octal conversion
Decimal to Non-Decimal
32. The decimal to binary conversion is
performed by repeatedly dividing
the decimal number by 2 till the
decimal number becomes zero and
then reading the remainders from
last to first to obtain the binary
equivalent to of the given decimal
number.
Examples 6.29 and 6.30, p114.
6.29: Convert the decimal number
30 into its equivalent binary number.
Decimal
Number
Divisor Quotient Remainder
30 2 15 0
15 2 7 1
7 2 3 1
3 2 1 1
1 2 0 1
Now, read the remainders
calculated in the above table in
upward direction to obtain the
binary equivalent, which is 11110.
Therefore, the binary equivalent of
the decimal number 30 is 11110.
Decimal to Binary Conversion
33. The decimal to hexadecimal conversion is performed by repeatedly dividing
the decimal number by 16 till the decimal number becomes zero and then
reading the remainders form last to first to obtain the binary equivalent to of
the given decimal number.
Decimal
Number
Divisor Quotient Remainder
1567 16 97 15(F)
97 16 6 1
6 16 0 6
Now, read the remainders calculated in the above table in upward
direction to obtain the hexadecimal equivalent, which is 61F. Therefore,
the hexadecimal equivalent of the decimal number 1567 is 61F.
Decimal to Hexa Conversion
Examples 6.34, p116: Convert the
decimal number 1567 into its
equivalent hexadecimal number.
34. The decimal to octal conversion is performed by repeatedly dividing the
decimal number by 8 till the decimal number becomes zero and then reading
the remainders form last to first to obtain the binary equivalent to of the given
decimal number.
Decimal
Number
Divisor Quotient Remainder
45796 8 5724 4
5724 8 715 4
715 8 89 3
89 8 11 1
11 8 1 3
1 8 0 1
Now, read the remainders calculated in the above table in upward
direction to obtain the octal equivalent, which is 131344. Therefore, the
octal equivalent of the decimal number 45796 is 131344.
Decimal to Octal Conversion
Examples
p117: Convert the decimal number
45796 to its equivalent octal number.
35. The given octal number can be converted into its
equivalent hexadecimal number in two different steps:
• (1) Convert the given octal number into its binary
equivalent by representing each digit in the octal
number to its equivalent 3-bit binary number.
• (2) Divide the binary number into 4-bit sections starting
from the least significant bit.
Octal to Hexadecimal
36. • Example 6.38, p119: Convert the octal number 365
into its equivalent hexadecimal number.
3
011
6
110
5
101
0000 1111 0101
0 F 5
Therefore, the equivalent hexadecimal number is F5.
Octal to Hexadecimal
37. 1! and 2 ! Complement
Fixed point representation and floating
point representation
+ve numbers are stored in register of digital
computer in sign magnitude form
Negative numbers are stored in three
different way
a. Signed magnitude representation
b. Signed 1s complement representation
c. Signed 2s complement representation
38. 1! and 2 ! Complement
Why do we require 1! and 2 ! Complement
One’s complement and two’s complement
are two important binary concepts. Two’s
complement is especially important because
it allows us to represent signed numbers in
binary, and one’s complement is the interim
step to finding the two’s complement.
Two’s complement also provides an easier
way to subtract numbers
39. 1! and 2 ! Complement
Example
9 radix 10 to binary is 0 0001001
Note : here MSB 0 indicate + sign
-9 radix 10 to binary is
a. 1 0001001 signed magnitude
b. 1 1110110 signed 1s complement
c. 1 1110111 signed 2s complement
Note : 2s complement can be formed by leaving
LSB unchanged and remaining taking 1s
complement
40. The BCD system is employed by computer systems to
encode the decimal number into its equivalent binary
number.
This is generally accomplished by encoding each digit of
the decimal number into its equivalent binary sequence.
The main advantage of BCD system is that it is a fast and
efficient system to convert the decimal numbers into
binary numbers as compared to the pure binary system.
4-Bit Binary Coded Decimal (BCD) Systems
41. The 4-bit BCD system is usually employed by the
computer systems to represent and process numerical
data only. In the 4-bit BCD system, each digit of the
decimal number is encoded to its corresponding 4-bit
binary sequence. The two most popular 4-bit BCD
systems are:
• Weighted 4-bit BCD code
• Excess-3 (XS-3) BCD code
4-Bit Binary Coded Decimal (BCD) Systems
42. The weighted 4-bit BCD code is more commonly known
as 8421 weighted code.
It is called weighted code because it encodes the
decimal system into binary system by using the concept
of positional weighting into consideration.
In this code, each decimal digit is encoded into its 4-bit
binary number in which the bits from left to right have
the weights 8, 4, 2, and 1, respectively.
Weighted 4-Bit BCD Code
43. Apart from 8421, some other weighted BCD codes are
4221, 2421 and 5211.
Decimal digits Weighted 4-bit BCD code
0 0000
1 0001
2 0010
3 0011
4 0100
5 0101
6 0110
7 0111
8 1000
9 1001
Weighted 4-Bit BCD Code
44. The Excess-3 (XS-3) BCD code
does not use the principle of
positional weights into
consideration while converting
the decimal numbers to 4-bit
BCD system. Therefore, we can
say that this code is a non-
weighted BCD code.
The function of XS-3 code is to
transform the decimal numbers
into their corresponding 4-bit
BCD code.
In this code, the decimal
number is transformed to the 4-
bit BCD code by first adding 3 to
all the digits of the number and
then converting the excess
digits, so obtained, into their
corresponding 8421 BCD code.
Therefore, we can say that the
XS-3 code is strongly related
with 8421 BCD code in its
functioning.
Excess-3 BCD Code
Decimal
digits
Excess-3 BCD code
0 0011
1 0100
2 0101
3 0110
4 0111
5 1000
6 1001
7 1010
8 1011
9 1100
45. Examples
Convert the decimal number 85 to XS-3 BCD code.
Add 3 to each digit of the given decimal number as:
8+3=11
5+3=8
The corresponding 4-bit 8421 BCD representation of the decimal digit 11 is
1011.
The corresponding 4-bit 8421 BCD representation of the decimal digit 8 is
1000.
Therefore, the XS-3 BCD representation of the decimal number 85 is 1011
1000.
Note:4-bit BCD systems are inadequate for representing and handling non-numeric data.
For this purpose, 6-bit BCD and 8-BCD systems have been developed.
Excess-3 BCD Code
46. The EBCDIC code is an 8-bit alphanumeric code that was
developed by IBM to represent alphabets, decimal digits
and special characters, including control characters.
The EBCDIC codes are generally the decimal and the
hexadecimal representation of different characters.
This code is rarely used by non IBM-compatible computer
systems.
EBCDIC Code
47. The ASCII code is pronounced as ASKEE and is used for the
same purpose for which the EBCDIC code is used. However,
this code is more popular than EBCDIC code as unlike the
EBCDIC code this code can be implemented by most of the
non-IBM computer systems.
Initially, this code was developed as a 7-bit BCD code to
handle 128 characters but later it was modified to an 8-bit
code.
ASCII Code
48. Gray code is another
important code that is also
used to convert the decimal
number into 8-bit binary
sequence. However, this
conversion is carried in a
manner that the contiguous
digits of the decimal
number differ from each
other by one bit only.
Gray Code
Decimal
Number
8-Bit Gray
Code
0 00000000
1 00000001
2 00000011
3 00000010
4 00000110
5 00000111
6 00001111
7 00001011
8 00001001
9 00001101