Upload
others
View
5
Download
0
Embed Size (px)
Citation preview
FLIPPED CLASS
F#3- Number System
Department of CSE, Coimbatore 1CTPS 2018
Common Number Systems
System Base Symbols
Used by
humans?
Used in
computers?
Decimal 10 0, 1, … 9 Yes No
Binary 2 0, 1 No Yes
Octal 8 0, 1, … 7 No No
Hexa-
decimal16
0, 1, … 9,
A, B, … FNo No
2Department of CSE, Coimbatore
The decimal system (base 10)
• The word decimal is derived from the Latin root decem (ten). In this
system the base b = 10 and we use ten symbols.
• The symbols in this system are often referred to as decimal digits or
just digits.
S = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}
3Department of CSE, Coimbatore
Integers
• Integers are generally represented in the form as …
Eg.
• The place values for the integer number +24 is …
4Department of CSE, Coimbatore
Real Numbers
• Real Numbers are generally represented in the form as …
Eg.
• The place values for the real number +24.13 is …
5Department of CSE, Coimbatore
The binary system (base 2)
• The word binary is derived from the Latin root bini(or two by two).
• In this system the base b = 2 and we use only two symbols.
• The symbols in this system are often referred to as binary digits or bits(binary digit).
6
S = {0, 1}
Department of CSE, Coimbatore
Decimal to Binary Conversion
• The number (156)10 in decimal is the same as (10011100)2 in binary.
• Let us see how the conversion is done!
Department of CSE, Coimbatore 7
Decimal to Binary Conversion Cntd..
• If the decimal number to be converted is (156.6875)10 , let us see how the
fractional part can be converted to binary!
Department of CSE, Coimbatore 8
• If the decimal number to be converted is (156.6875)10 , let us see how the fractional part
can be converted to binary!
• The binary of (156)10 is (10011100)2 and the binary of (0.6875)10 is (0.1011)2
So the complete answer is (156.6875)10 = (10011100.1011)2
Department of CSE, Coimbatore 9
• The number (11001)2 in binary is the same as 25 in decimal and is represented as…
• The equivalent decimal number is N = 16 + 8 + 0 + 0 + 1 = 25.
Department of CSE, Coimbatore 10
• The number (101.11)2 in binary is equal to the number 5.75 in decimal .
Department of CSE, Coimbatore 11
✓Can you perform the indicated conversion?
Department of CSE, Coimbatore
Decimal to Binary
a) 1310 = ?
b) 2210 = ?
c) 4310 = ?
d) 15810 = ?
Binary to Decimal
a) 0110 2 = ?
b) 11010 2 = ?
c) 0110101 2 = ?
d) 11010011 2 = ?
12
Decimal → Binary ………..Answers
a) 1310 = ?
b) 2210 = ?
c) 4310 = ?
d) 15810 = ?
1 1 0 1 2
1 0 1 1 0 2
1 0 1 0 1 1 2
1 0 0 1 1 1 1 0 2
Department of CSE, Coimbatore 13
Binary → Decimal ……….Answers
a) 0110 2 = ?
b) 11010 2 = ?
c) 0110101 2 = ?
d) 11010011 2 = ?
6 10
26 10
53 10
211 10
Department of CSE, Coimbatore 14
The hexadecimal system (base 16)
• The word hexadecimal is derived from the Greek root hex (six) and the Latin root decem (ten).
• In this system the base b = 16 and we use sixteen symbols to represent a number.
• The set of symbols are:
Note that the symbols A, B, C, D, E, F are equivalent to 10, 11, 12, 13, 14, and 15 respectively.
The symbols in this system are often referred to as hexadecimal digits.
S = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9,A, B, C, D, E, F}
Department of CSE, Coimbatore 15
• The number (2AE)16 in hexadecimal is equivalent to 686 in decimal is represented as…
• The equivalent decimal number is N = 512 + 160 + 14 = 686.Department of CSE, Coimbatore 16
Converting from base 10 to base 3
3 4 10 = __________3
33 32 3 1
3 3 4
1 1 - 13
3 - 23
1 - 0
1 0 2 1
Department of CSE, Coimbatore 17
Decimal to any base – Integral part
Department of CSE, Coimbatore 18
Decimal to any base – Fractional part
Department of CSE, Coimbatore 19
Binary-octal (base 8) conversion
• The binary bits are grouped into 3 and converted….
• Binary to octal and octal to binary conversion. Eg.
Department of CSE, Coimbatore 20
Binary-hexadecimal conversion
Department of CSE, Coimbatore
• The binary bits are grouped into 4 and converted…
• Binary to hexadecimal and hexadecimal to binary conversion. Eg.
21
Octal (base 8)-hexadecimal conversion
• Convert into binary first and then perform the required conversion.
• Octal to hexadecimal and hexadecimal to octal conversion. Eg.
Department of CSE, Coimbatore 22
Try it yourself✓Convert these binary numbers into octal numbers...
(a) 001011112 (8 bits) (b) 111101002 (8 bits)
✓Convert the following octal numbers into hexadecimal (16 bits)
(a) 658 (b) 1238
Can you find out .........
✓What is the biggest binary number one can write with n bits?
✓How many unique patterns does a sequence of 5 bits generate?
✓Write all the patterns of a sequence of 5 bits.Department of CSE, Coimbatore 23
Try it yourself
Department of CSE, Coimbatore
✓Convert these binary numbers into octal numbers...
(a) 001011112 (8 bits) (b) 111101002 (8 bits)
✓Convert the following octal numbers into hexadecimal (16 bits)
(a) 658 (b) 1238
Can you find out .........
✓What is the biggest binary number one can write with n bits?
✓How many unique patterns does a sequence of 5 bits generate?
✓Write all the patterns of a sequence of 5 bits.
24
Binary → Octal ........ Answers
Refer to the binary-octal
conversion table
000 101 111
= 578
0 5 7
Refer to the binary-octal
conversion table
011 110 100
= 3648
3 6 4
Department of CSE, Coimbatore 25
Refer to the binary-octal conversion table
68 58
110 101
0000 0000 0011 01012
0 0 3 5
= 3516
Refer to the binary-octal conversion table
18 28 38
001 010 011
0000 0000 0101 00112
0 0 5 3
= 5316
Octal → Hexadecimal Answers
Department of CSE, Coimbatore 26
Conversion from Hexadecimal to Binary
Replace each hex digit by the 4 equivalent bits, for examples,
• A3C5H = 1010 0011 1100 0101B
• 102AH = 0001 0000 0010 1010B
27Department of CSE, Coimbatore
Conversion from Binary to Hexadecimal
Starting from the right-most bit (least-significant bit), replace each group of 4 bits by
the equivalent hex digit (pad the left-most bits with zero if necessary), for example,
• 1001001010B = 0010 0100 1010B = 24AH
• 10001011001011B = 0010 0010 1100 1011B = 22CBH
28Department of CSE, Coimbatore
Exercises (Number Systems Conversion)
Convert the following decimal numbers into binary and hexadecimal numbers:
• 108
• 4848
• 9000
29
Answers……………
• 108 = 1101100 = 6C
• 4848 = 1001011110000 = 12F0
• 9000 = 10001100101000 = 2328
Depart
ment
of
CSE,
Coimb
atore
30
Exercises (Number Systems Conversion)
Convert the following binary numbers into hexadecimal and decimal numbers:
• 1000011000
• 10000000
• 101010101010
31
Answers……………
• 1000011000 = 218H = 536D
• 10000000 = 80H = 128D
• 101010101010 = AAAH = 2730D
Depart
ment
of
CSE,
Coimb
atore
32
Exercises (Number Systems Conversion)
Convert the following hexadecimal numbers into binary and decimal numbers:
• ABCDE
• 1234
• 80F
33
Answers……………
• ABCDE = 10101011110011011110 = 703710D
• 1234 = 1001000110100 = 4660D
• 80F = 100000001111 = 2063D
34
Exercises (Number Systems Conversion)
Convert the following decimal numbers into binary equivalent:
• 19.25D
• 123.456D
35
Answers……………
• 19.25 = 10011.01
• 123.456 = 1111011.01110100…
Depart
ment
of
CSE,
Coimb
atore
36