Number System: Khaliq Ahmad

Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 65

Number System

Compiled By:
Khaliq Ahmad
Chapter Goals

 Know the different types of numbers


 Describe positional notation
 Convert numbers in other bases to base 10
 Convert base 10 numbers into numbers of other
bases
 Describe the relationship between bases 2, 8, and
16
 Explain computing and bases that are powers of 2

2 Number System 24
6
Number Representations
 There are basically two ways of representing
the numerical value of quantities: analog and
digital.
Analog Representation

 In analog representation a quantity is


represented by a voltage, current, or meter
movement that is proportional to the value of
that quantity.
 Analog quantities such as those cited above
have an important characteristic: they can vary
over a continuous range of values.
Analog Voltage vs Time
Digital Representation

 In digital representation the quantities are


represented not by proportional quantities but by
symbols called digits.
 As an example, consider the digital watch, which
provides the time of day in the form of decimal
digits which represent hours and minutes (and
sometimes seconds).
 This digital representation of the time of day
changes in discrete steps, as compared with the
representation of time provided by an analog
watch, where the dial reading changes
continuously.
Digital Voltage vs Time
Difference between Analog and
Digital quantities
 The major difference between analog and
digital quantities, then, can be simply stated as
follows:
 Analog = continuous
Digital = discrete (step by step)
Digital Number System

 Many number systems are in use in digital


technology. The most common are the decimal,
binary, octal, and hexadecimal systems.
 The decimal system is clearly the most familiar
to us because it is a tool that we use every day.
 Examining some of its characteristics will help
us to better understand the other systems.
Introduction to Number systems

 In additional to binary and decimal, two other


number systems find wide-spread applications
in digital systems.
 The octal (base-8) and hexadecimal (base-16)
number systems are both used for the same
purpose- to provide an efficient means for
representing large binary system.
Number System
 You may regard each digit as a box that can hold
a number. In the binary system, there can be only
two choices for this number -- either a "0" or a "1".
In the octal system, there can be eight
possibilities: "0", "1", "2", "3", "4", "5", "6", "7".
 In the decimal system, there are ten different
numbers that can enter the digit box: "0", "1", "2",
"3", "4", "5", "6", "7", "8", "9".
 In the hexadecimal system, we allow 16 numbers:
"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B",
"C", "D", "E", and "F".
Numbers

Natural Numbers
Zero and any number obtained by repeatedly adding
one to it.

Examples: 100, 0, 45645, 32

Negative Numbers
A value less than 0, with a – sign

Examples: -24, -1, -45645, -32

12 Number System
Numbers (Cont’d)

Integers
A natural number, a negative number, zero

Examples: 249, 0, - 45645, - 32

Rational Numbers
An integer or the quotient of two integers

Examples: -249, -1, 0, ¼ , - ½

13 Number System 3
Exponents

 20 = 1
 21 = 2
 22 = 2 x 2 =4
 23 = 2 x 2 x 2 = 8
 x5 + x10 = x15
 1 / x2 = x -2

14 Number System
Bit & Byte
 Computer uses the binary system. Any physical
system that can exist in two distinct states (e.g., 0-
1, on-off, hi-lo, yes-no, up-down, north-south, etc.)
has the potential of being used to represent
numbers or characters.
 A binary digit is called a bit. There are two
possible states in a bit, usually expressed as 0
and 1.
 A series of eight bits strung together makes a
byte, much as 12 makes a dozen. With 8 bits, or 8
binary digits, there exist 2^8=256 possible
K&M

 2^10=1024 is commonly referred to as a "K". It


is approximately equal to one thousand. Thus,
1 Kbyte is 1024 bytes.
 Likewise, 1024K is referred to as a "Meg". It is
approximately equal to a million. 1 Mega byte
is 1024*1024=1,048,576 bytes.
 If you remember that 1 byte equals one
alphabetical letter, you can develop a good feel
for size.
Decimal System

 The decimal system is composed of 10


numerals or symbols.
 These 10 symbols are 0, 1, 2, 3, 4, 5, 6, 7, 8, 9;
using these symbols as digits of a number, we
can express any quantity.
 The decimal system, also called the base-10
system because it has 10 digits.
Binary System

 In the binary system, there are only two


symbols or possible digit values, 0 and 1.
 This base-2 system can be used to represent
any quantity that can be represented in
decimal or other number system.
Binary Counting
Introduction to Number systems
 The binary number system is the most
important one in digital systems, but several
others are also important.
 The decimal system is important because it is
universal used to represent quantities outside a
digital system. This means that there will be
situations where decimal values have to be
converted to binary values before they are
entered into the digital system
Decimal Numbering systems

 Base: 10
 Digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
 Representation
5234
 Thousands Hundreds Tens Units
5 2 3 4

21 Number System
Decimal Numbering systems

 Example: 523410

 103 = 1000 102 = 100 101 = 10 100 = 1


5 2 3 4

5,234 = 5 x 1000 + 2 x 100 + 3 x 10 + 4 x 1


 

22 Number System
Positional Notation

Continuing with our example…


642 in base 10 positional notation is:

6 x 10² = 6 x 100 = 600


+ 4 x 10¹ = 4 x 10 = 40
+ 2 x 10º = 2 x 1 = 2 = 642 in
base 10
The power indicates
This number is in the position of
base 10 the number
23 Number System
Positional Notation

As a formula:

 dn * Rn-1 + dn-1 * Rn-2 + ... + d2 * R + d1

d is the digit in the


n is the number of R is the base
ith position
digits in the number of the number
in the number

642 is:  63 * 102 +  42 * 10 +  21


24 Number System
Positional Notation

What if 642 has the base of 13?

+ 6 x 13² = 6 x 169 = 1014


+ 4 x 13¹ = 4 x 13 = 52
+ 2 x 13º = 2 x 1 = 2
= 1068 in base 10

642 in base 13 is equivalent to 1068 in base 10

25 Number System
Binary Numbering systems

 Base: 2
 Digits: 0, 1
 binary number: 1101012
positional powers of 2: 25 24 23 22 21 20
decimal positional value: 32 16 8 4 2
1
binary number: 1 1 0 1 0 1

26 Number System
Converting Binary to Decimal

What is the decimal equivalent of the binary number


010110 ?
1 x 26 = 1 x 64 = 64
+ 1 x 25 = 1 x 32 = 32
+ 0 x 24 = 0 x 16 =0
+ 1 x 23 = 1x8 =8
+ 1 x 22 = 1x4 =4
+ 1 x 21 = 1x2 =2
+ 0 x 2º = 0x1 =0
= 112 in base 10
27 Number System
Binary to Decimal Conversion

 To convert to base 10, add all the values where


a one digit occurs.
Ex: 1101012
positional powers of 2: 25 24 23 22 21 20
decimal positional value: 32 16 8 4 2 1
binary number: 1 1 0 1 0 1
32 + 16 + 4 + 1 = 5310

28 Number System
Binary to Decimal Conversion

Ex: 1010112
positional powers of 2: 25 24 23 22 21 20
decimal positional value:
binary number:

29 Number System
Decimal to Binary Conversion
The Division Method. Divide by 2 until you reach zero, and
then collect the remainders in reverse.
  Ex 1: 5610 = 1110002
2 ) 56 Rem:
2 ) 28 0
2 ) 14 0
2) 7 0
2) 3 1
2) 1 1
0 1

30 Number System
Decimal to Binary Conversion

Ex 2: 3510 =

2) Rem:
2)
2)
2)
2)
2)
Answer: 3510 = 2
 

31 Number System
Decimal to Binary Conversion

The Subtraction Method:


Subtract out largest power of 2 possible
(without going below zero) each time until you
reach 0. Place a one in each position where
you were able to subtract the value, and a 0 in
each position that you could not subtract out
the value without going below zero.

32 Number System
Decimal to Binary Conversion

Ex 1: 5610
56 2 6 | 25 2 4 2 3 2 2 2 1 2 0
- 32 64 | 32 16 8 4 2 1
24 | 1 1 1 0 0 0
- 16
8
- 8
0
  Answer: 5610 = 1110002

33 Number System
Decimal to Binary Conversion

Ex 2: 3810
38 2 6 | 25 2 4 2 3 2 2 2 1 2 0
|
|

  Answer: 3810 = 2

34 Number System
Character Representation
ASCII Table
Rightmost Leftmost Three Bits
Four Bits 000 001 010 011 100 101 110 111
0000 NUL DLE Space 0 @ P ` p
0001 SOH DC1 ! 1 A Q a q
0010 STX DC2 " 2 B R b r
0011 ETX DC3 # 3 C S c s
0100 EOT DC4 $ 4 D T d t
0101 ENQ NAK % 5 E U e u
0110 ACK SYN & 6 F V f v
0111 BEL ETB ' 7 G W g w
1000 BS CAN ( 8 H X h x
1001 HT EM ) 9 I Y I y
1010 LF SUB * : J Z j z
1011 VT ESC + ; K [ k {
1100 FF FS , < L \ l |
1101 CR GS - = M ] m }
1110 SO RS . > N ^ n ~
1111 SI US / ? O _ o DEL

35 Number System
Character Representation

Ex: Find the binary ASCII and decimal ASCII values for the ‘&’
character.
Rightmost Leftmost Three Bits
  Four Bits
0000
000
NUL
001
DLE
010
Space
011
0
100
@
101
P
110
`
111
p
0001 SOH DC1 ! 1 A Q a q
0010 STX DC2 " 2 B R b r
0011 ETX DC3 # 3 C S c s
0100 EOT DC4 $ 4 D T d t
0101 ENQ NAK % 5 E U e u
0110 ACK SYN & 6 F V f v
0111 BEL ETB ' 7 G W g w
1000 BS CAN ( 8 H X h x
1001 HT EM ) 9 I Y I y
1010 LF SUB * : J Z j z
1011 VT ESC + ; K [ k {
1100 FF FS , < L \ l |
1101 CR GS - = M ] m }
1110 SO RS . > N ^ n ~
1111 SI US / ? O _ o DEL

36 Number System
Character Representation
ASCII Table

From the chart:


‘&’ = 0100110 (binary ASCII value)

Convert the binary value to decimal:


01001102 = 32 + 4 + 2 = 3810
 
Therefore:
‘&’ = 38 (decimal ASCII value)

37 Number System
Octal Numbering systems

 Base: 8
 Digits: 0, 1, 2, 3, 4, 5, 6, 7
 Octal number: 12468
powers of : 84 83 82 81 80
decimal value: 4096 512 64 8 1
Octal number: 1 2 4 6

38 Number System
Octal to Decimal Conversion
 To convert to base 10, beginning with the
rightmost digit multiply each nth digit by 8(n-1),
and add all of the results together.
Ex: 12468
positional powers of 8: 8 3 8 2 81 8 0
decimal positional value: 512 64 8 1
Octal number: 1 2 4 6
512 + 128 + 32 + 6 = 67810

39 Number System
Octal to Decimal Conversion

Ex: 103528
positional powers of 8: 84 83 82 81 80
decimal positional value:
Octal number:

40 Number System
Decimal to Octal Conversion
The Division Method. Divide by 8 until you reach zero, and
then collect the remainders in reverse.
  Ex 1: 433010 = 103528
8 ) 4330 Rem:
8 ) 541 2
8 ) 67 5
8) 8 3
8) 1 0
0 1

41 Number System
Decimal to Octal Conversion

Ex 2: 81010 =

8 ) 810 Rem:
8)
8)
8)

Answer: 81010 = 8
 

42 Number System
Hexadecimal Numbering systems

 Base: 16
 Digits: 0, 1, 2, 3, 4, 5, 6, 7,8,9,A,B,C,D,E,F
 Hexadecimal number: 1F416
powers of : 164 163 162 161 160
decimal value: 65536 4096 256 16 1
Hexadecimal number: 1 F 4

43 Number System
Hexadecimal Numbering systems

Four-bit Group Decimal Digit Hexadecimal Digit


0000 0 0
0001 1 1
0010 2 2
0011 3 3
0100 4 4
0101 5 5
0110 6 6
0111 7 7
1000 8 8
1001 9 9
1010 10 A
1011 11 B
1100 12 C
1101 13 D
1110 14 E
1111 15 F

44 Number System
Hexa to Decimal Conversion
 To convert to base 10, beginning with the
rightmost digit multiply each nth digit by 16(n-1),
and add all of the results together.
Ex: 1F416
positional powers of 16: 163 162 161 160
decimal positional value: 4096 256 16 1
Hexadecimal number: 1 F 4
256 + 240 + 4 = 50010

45 Number System
Hexa to Decimal Conversion

Ex: 7E16
positional powers of 16: 163 162 161 160
decimal positional value:
Hexa number:

46 Number System
Converting Hexadecimal to
Decimal

What is the decimal equivalent of the hexadecimal


number DEF?

D x 16² = 13 x 256 = 3328


+ E x 16¹ = 14 x 16 = 224
+ F x 16º = 15 x 1 = 15
= 3567 in base 10

Remember, base 16 is
0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F
47 Number System
Decimal to Hexa Conversion

The Division Method. Divide by 16 until you


reach zero, and then collect the remainders in
reverse.
  Ex 1: 12610 = 7E16
16) 126 Rem:
16) 7 14=E
0 7

48 Number System
Decimal to Hexa Conversion

Ex 2: 81010 =

16 ) 810 Rem:
16 )
16 )

Answer: 81010 = 16
 

49 Number System
Binary to Octal Conversion

Since the maximum value represented in 3 bit is equal


to:
23 – 1 = 7
i.e. using 3 bits we can represent values from 0 –7
which are the digits of the Octal numbering system.
Thus, three binary digits can be converted to one octal
digit.

50 Number System
Binary to Octal Conversion
Three-bit Group Decimal Digit Octal Digit
000 0 0
001 1 1
010 2 2
011 3 3
100 4 4
101 5 5
110 6 6
111 7 7

51 Number System
Octal to Binary Conversion

Ex :
Convert 7428 = 2

7 = 111
4 = 100
2 = 010

7428 = 111 100 0102

52 Number System
Binary to Octal Conversion

Ex :
Convert 101001102 = 8

110 = 6
100 = 4
010 = 2 ( pad empty digits with 0)

101001102 = 2468

53 Number System
Binary to Hexa Conversion

Since the maximum value represented in 4 bit is equal


to:
24 – 1 = 15
i.e. using 4 bits we can represent values from 0 –15
which are the digits of the Hexadecimal numbering
system.
Thus, Four binary digits can be converted to one
Hexadecimal digit.

54 Number System
Binary to Hexa conversion

Four-bit Group Decimal Digit Hexadecimal Digit


0000 0 0
0001 1 1
0010 2 2
0011 3 3
0100 4 4
0101 5 5
0110 6 6
0111 7 7
1000 8 8
1001 9 9
1010 10 A
1011 11 B
1100 12 C
1101 13 D
1110 14 E
1111 15 F

55 Number System
Hexa to Binary Conversion

Ex :
Convert 3D98 = 2

3 = 0011
D = 1101
9 = 1001

3D98 = 0011 1101 10012

56 Number System
Binary to Hexa Conversion

Ex :
Convert 101001102 = 8

0110 = 6
1010 = A

101001102 = A616

57 Number System
Octal to Hexa Conversion

 To convert between Octal to Hexadecimal


numbering systems and visa versa convert from
one system to binary first then convert from
binary to the new numbering system

58 Number System
Hexa to Octal Conversion

Ex :
Convert E8A16 = 8

1110 1000 10102

111 010 001 010 (group by 3 bits)

7 2 1 2

E8A16 = 72178

59 Number System
Octal to Hexa Conversion

Ex :
Convert 7528 = 16

111 101 0102 (group by 4 bits)

0001 1110 1010

1 E A

7528 = 1EA16

60 Number System
Hexa to Octal ( Example No 2 )

 Convert Hexadecimal number to binary,


giving a group of FOUR BITS for each Hex
digit
 Cut the bits into groups of three, starting from
the left.
 Convert Groups of three bits to OCTAL

61 Number System
Hexa to Octal ( Example No 2 )

3 A  Hex 3A

0011 1010  Convert to 4-bit binary

000 111 010  Group into 3-bit binary

072  Convert to Octal

62 Number System
Octal to Hexa ( Example No 2 )

 Convert OCTAL number to binary, giving a


group of THREE BITS for each Octal digit
 Cut the bits into groups of FOUR, starting
from the left.
 Convert groups of four into HEXIDECIMAL

63 Number System
Octal to Hexa ( Example No 2 )

3 7 2  Octal 372

011 111 010  Convert to 3-bit binary

1111 1010  Group into 4-bit binary

F A  Convert to Hex

64 Number System
Arithmetic in Binary

• Remember: there are only 2 digits in binary:


0 and 1
• Position is key, carry values are used:

1 11111 Carry Values


1010111
+1 0 0 1 0 1 1
10100010

65 Number System

You might also like