SlideShare une entreprise Scribd logo
1  sur  25
Télécharger pour lire hors ligne
CS221: Digital Design
Number SystemNumber System
Dr. A. Sahu
Dept of Comp. Sc. & Engg.Dept of Comp. Sc. & Engg.
Indian Institute of Technology Guwahati
1
OutlineOutline
• Number System
D i l Bi O t l H– Decimal, Binary, Octal, Hex
• Conversion (one to another)
– Decimal to Binary Octal Hex & Vice VersaDecimal to Binary, Octal, Hex   & Vice Versa
– Binary to HEX & vice versa
• Other representation
– Signed, Unsigned, Complement
• Operation
– Add, Sub, Mul, Div, Mod
• How to handle real number efficiently  ?
Float Double– Float, Double
2
What Digit? => Number SystemWhat Digit?   > Number System 
• Famous Number System: Dec Rom BinFamous Number System: Dec, Rom, Bin
• Decimal System: 0 ‐9
M l b h h 10 fi– May evolves: because human have 10 finger 
• Roman System
– May evolves to make easy to look and feel
– Pre/Post Concept: (IV,  V  & VI) is (5‐1, 5 & 5+1) 
• Binary System, Others (Oct, Hex)
– One can cut an apple in to twopp
3
Significant DigitsSignificant Digits
Binary: 11101101Binary: 11101101
Most significant digit Least significant digitMost significant digit                   Least significant digit
Decimal: 1063079Decimal:  1063079
Most significant digit Least significant digitMost significant digit                   Least significant digit
Decimal (base 10)Decimal (base 10)
• Uses positional representationUses positional representation
• Each digit corresponds to a power of 10 based 
on its position in the numberon its position in the number
• The powers of 10 increment from 0, 1, 2, etc. 
i h l fas you move right to left
– 1,479 = 1 * 103 + 4 * 102 + 7 * 101 + 9 * 100
Binary (base 2)Binary (base 2) 
• Two digits: 0, 1
• To make the binary numbers more y
readable, the digits are often put in groups 
of 4
– 1010 = 1 * 23 + 0 * 22 + 1 * 21 + 0 * 20 
= 8 + 2 
= 10= 10 
– 1100 1001 = 1 * 27 + 1 * 26 + 1 * 23 + 1 * 20 
= 128 + 64 + 8 + 1 128   64   8   1 
= 201
How to Encode Numbers: Binary 
NumbersNumbers
• Working with binary numbers
In base ten helps to know powers of 10–In base ten, helps to know powers of 10
• one, ten, hundred, thousand, ten thousand, ...
I b t h l t k f 2–In base two, helps to know powers of 2
• one, two, four, eight, sixteen, thirty two, sixty 
f h d d t t i htfour, one hundred twenty eight
• Count up by powers of two
24 23 22 21 2029 28 27 26 25 a
16 8 4 2 1512 256 128 64 32
Octal (base 8)Octal (base 8)
• Shorter & easier to read than binary
• 8 digits: 0, 1, 2, 3, 4, 5, 6, 7, 
• Octal numbersOctal numbers
1368 = 1 * 82 + 3 * 81 + 6 * 80 
1 * 64 3 * 8 6 * 1= 1 * 64 + 3 * 8 +  6 * 1
= 9410
Hexadecimal (base 16)Hexadecimal (base 16)
• Shorter & easier to read than binary
• 16 digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F
• “0x” often precedes hexadecimal numbers0x  often precedes hexadecimal numbers
0x123 = 1 * 162 + 2 * 161 + 3 * 160 
1 * 256 2 * 16 3 * 1= 1 * 256 + 2 * 16 +  3 * 1
= 256 + 32 +  3
= 291 
Counting
Decimal Binary Octal Hexadecimal
0 00000 0 0
Counting 1 00001 1 1
2 00010 2 2
3 00011 3 3
4 00100 4 4
5 00101 5 5
6 00110 6 66 00110 6 6
7 00111 7 7
8 01000 10 8
9 01001 11 9
10 01010 12 A
11 01011 13 B
12 01100 14 C
13 01101 15 D
14 01110 16 E14 01110 16 E
15 01111 17 F
16 10000 20 10
10
Fractional NumberFractional Number 
• Point: Decimal Point, Binary Point, Hexadecimal 
point
• Decimal
247.75   = 2x102+4x101+7x100+7x10‐1+5x10‐2
• BinaryBinary
10.101= 1x21+0x20+1x2‐1+0x2‐2+1x2‐3
• Hexadecimal• Hexadecimal
6A.7D=6x161+10x160+7x16‐1+Dx16‐2
Converting To and From DecimalConverting To and From Decimal
Successive 
Division
Weighted 
M lti li ti
Decimal100 1 2 3 4 5 6 7 8 9
Weighted 
Multiplication
Successive 
Division
Multiplication
Successive 
Di i i
Weighted 
M lti li ti
Octal8
0 1 2 3 4 5 6 7
Hexadecimal16
0 1 2 3 4 5 6 7 8 9 A B C D E F
Division Multiplication
BinaryBinary2
0 1
12
Decimal ↔ BinaryDecimal ↔ Binary
SuccessiveSuccessive
Division
a) Divide the decimal number by 2; the remainder is the LSB of the binary) y ; y
number.
b) If the quotation is zero, the conversion is complete. Otherwise repeat step 
(a) using the quotation as the decimal number. The new remainder is the ( ) g q
next most significant bit of the binary number.
Weighted
a) Multiply each bit of the binary number by its corresponding bit‐
Multiplication
weighting factor (i.e., Bit‐0→20=1; Bit‐1→21=2; Bit‐2→22=4; etc). 
b) Sum up all of the products in step (a) to get the decimal number.  
Decimal  to Binary : Subtraction Methody
• Goal Desired decimal number: 12
– Good for human
– Get the binary weights to 
dd t th d i l
Desired decimal number: 12
1 =32
12481632
add up to the decimal 
quantity
• Work from left to right
12481632 too much
12481632
0 =16
too much
1
• (Right to left – may fill in 1s 
that shouldn’t have been 
there – try it). 
a
12481632
0 =8
ok, keep going
0 1
12481632
0 =8+4=12
DONE
0 1 1
0 0 1 1 0 0
12481632
0 answer0 1 1 0 0
Decimal to Binary : Division Methody
• Good for computer:  Divide decimal number by 2 and 
insert remainder into new binary number.y
– Continue dividing quotient by 2 until the quotient is 0.
• Example: Convert decimal number 12 to binary
12 div 2  =   ( Quo=6 , Rem=0)   LSB
( )6 div 2  =    (Quo=3, Rem=0)
3 div 2  =     (Quo=1,Rem=1)
1 div 2 = ( Quo=0 Rem=1) MSB1 div 2  =   ( Quo=0, Rem=1)   MSB 
1210= 1 1 00 21210  1 1 00 2 
Conversion Process Decimal ↔ BaseNN
SuccessiveSuccessive
Division
a) Divide the decimal number by N; the remainder is the LSB of the ANY ) y ;
BASE Number .
b) If the quotient is zero, the conversion is complete. Otherwise repeat 
step (a) using the quotient as the decimal number.  The new remainder p ( ) g q
is the next most significant bit of the ANY BASE number.
Weighted
a) Multiply each bit of the ANY BASE number by its corresponding bit‐
Multiplication
weighting factor (i.e., Bit‐0→N0; Bit‐1→N1; Bit‐2→N2; etc). 
b) Sum up all of the products in step (a) to get the decimal number.  
Decimal ↔ Octal ConversionDecimal ↔ Octal Conversion
The Process: Successive Division
• Divide  number by 8;  R is the LSB of the octal number 
• While Q is 0 
• Using the Q as the decimal number. 
• New remainder is MSB of the octal number.
LSB6r
11
948 ←=
3r
1
118 =
9410 = 1368
MSB1r
0
18 ←= 17
Decimal ↔ Hexadecimal ConversionDecimal ↔ Hexadecimal Conversion
The Process: Successive Division
• Divide  number by 16;  R is the LSB of the hex
number 
• While Q is 0 
• Using the Q as the decimal number.  
• New remainder is MSB of the hex number.
S
5
MSB5
0
516
LSBEr9416 ←=
9410 = 5E16
MSB5r516 ←=
Example: Hex → OctalExample: Hex → Octal
Example:
C h h d i l b 5A i i l i lConvert the hexadecimal number 5AH into its octal equivalent.
Solution:
First convert the hexadecimal number into its decimal equivalent then
5 A
First convert the hexadecimal number into its decimal equivalent, then 
convert the decimal number into its octal equivalent.
LSB2r
11
908 ←=5 A
16
1
16
0
16 1
3r
1
118
LSB2r908
=
←=
16 1
80 + 10 = 9010 MSB1r
0
18 ←=
∴ 5AH = 1328
19
Example: Octal → BinaryExample: Octal → Binary
Example:
Convert the octal number 132 into its binary equivalentConvert the octal number 1328 into its binary equivalent.
Solution:
First convert the octal number into its decimal equivalent, then convert the 
d l b b l
1 3 2
22
LSB0r
45
902 ←=
decimal number into its binary equivalent.
1328 = 10110102
82 81 80
64 8 1
5
0r
11
222
1r
22
452
=
=
64 + 24 + 2 = 9010
1
1r
2
52
1r
5
112
=
=
MSB1r
0
12
0r
1
22
←=
=
20
Binary ↔ Octal ↔ Hex ShortcutBinary ↔ Octal ↔ Hex Shortcut
• Relation
Bi l d h b• Binary, octal, and hex number systems 
• All powers of two
• Exploit (This Relation) 
•Make conversion easier.
21
Substitution Code
Convert 0101011010101110011010102 to hex using
Substitution Code
Convert 0101011010101110011010102 to hex using 
the 4‐bit substitution code :
5 6 A E 6 A
0101  0110  1010  1110  0110  1010
56AE6A16
Substitution CodeSubstitution Code
Substitution code can also be used to convert binary to 
octal by using 3‐bit groupings: 
2 5 5 2 7 1 5 2
010   101  101 010 111  001  101  010
255271528
Other RepresentationOther Representation 
• Signed & Unsigned Number
Si d b l bi ( MSB) i i d bi• Signed number last bit (one MSB) is signed bit
Assume: 8 bit number 
Unsigned 12 :    0000 1100 
Signed +12   :    0000 1100   
Signed ‐12     :   1000 1100   
• Complement numberp
Unsigned  binary   12   = 00001100
1’s Complement of 12 = 1111 00111 s Complement of 12 = 1111 0011
24
Thanks
25

Contenu connexe

Tendances

Tendances (20)

BINARY NUMBER SYSTEM
BINARY NUMBER SYSTEMBINARY NUMBER SYSTEM
BINARY NUMBER SYSTEM
 
Hexadecimal to octal conversion
Hexadecimal to octal conversionHexadecimal to octal conversion
Hexadecimal to octal conversion
 
Number system
Number systemNumber system
Number system
 
Digital Electronics- Number systems & codes
Digital Electronics- Number systems & codes Digital Electronics- Number systems & codes
Digital Electronics- Number systems & codes
 
Number system conversion
Number system conversionNumber system conversion
Number system conversion
 
Binary codes
Binary codesBinary codes
Binary codes
 
Number system....
Number system....Number system....
Number system....
 
Convert Hexadecimal to decimal
Convert Hexadecimal to decimalConvert Hexadecimal to decimal
Convert Hexadecimal to decimal
 
Conversion of number system
Conversion of number systemConversion of number system
Conversion of number system
 
Binary number system
Binary number systemBinary number system
Binary number system
 
Number System
Number SystemNumber System
Number System
 
Computer number systems
Computer number systemsComputer number systems
Computer number systems
 
Floating point representation
Floating point representationFloating point representation
Floating point representation
 
11 octal number system
11   octal number system11   octal number system
11 octal number system
 
Basic of number system
Basic of number systemBasic of number system
Basic of number system
 
Digital logic design part1
Digital logic design part1Digital logic design part1
Digital logic design part1
 
Number system
Number systemNumber system
Number system
 
Advantage of binary number system
Advantage of binary number systemAdvantage of binary number system
Advantage of binary number system
 
Number systems ppt
Number systems pptNumber systems ppt
Number systems ppt
 
Number System
Number SystemNumber System
Number System
 

Similaire à CS221: Guide to Number Systems

Similaire à CS221: Guide to Number Systems (20)

More on number system
More on number systemMore on number system
More on number system
 
Digital Electronics – Unit I.pdf
Digital Electronics – Unit I.pdfDigital Electronics – Unit I.pdf
Digital Electronics – Unit I.pdf
 
03_NumberSystems.pdf
03_NumberSystems.pdf03_NumberSystems.pdf
03_NumberSystems.pdf
 
Chapter 2.1 introduction to number system
Chapter 2.1 introduction to number systemChapter 2.1 introduction to number system
Chapter 2.1 introduction to number system
 
Number system
Number systemNumber system
Number system
 
dld 01-introduction
dld 01-introductiondld 01-introduction
dld 01-introduction
 
Digital Logic
Digital LogicDigital Logic
Digital Logic
 
Intro to IT Skills Lec 5 - English Department.pptx
Intro to IT Skills Lec 5 - English Department.pptxIntro to IT Skills Lec 5 - English Department.pptx
Intro to IT Skills Lec 5 - English Department.pptx
 
Basic arithmetic, instruction execution and program
Basic arithmetic, instruction execution and programBasic arithmetic, instruction execution and program
Basic arithmetic, instruction execution and program
 
Digital Electronics Notes.pdf
Digital Electronics Notes.pdfDigital Electronics Notes.pdf
Digital Electronics Notes.pdf
 
Numbering Systems
Numbering SystemsNumbering Systems
Numbering Systems
 
LEC 1.pptx
LEC 1.pptxLEC 1.pptx
LEC 1.pptx
 
1. basic theories of information
1. basic theories of information1. basic theories of information
1. basic theories of information
 
Number Systems.pptx
Number Systems.pptxNumber Systems.pptx
Number Systems.pptx
 
Lecture
LectureLecture
Lecture
 
chapter 1.pptx
chapter 1.pptxchapter 1.pptx
chapter 1.pptx
 
Digital Logic Design.pptx
Digital Logic Design.pptxDigital Logic Design.pptx
Digital Logic Design.pptx
 
JPC#8 Foundation of Computer Science
JPC#8 Foundation of Computer ScienceJPC#8 Foundation of Computer Science
JPC#8 Foundation of Computer Science
 
Number_Systems (2).ppt
Number_Systems (2).pptNumber_Systems (2).ppt
Number_Systems (2).ppt
 
data representation
 data representation data representation
data representation
 

Plus de Raj vardhan

Software Testing Life Cycle Unit-3
Software Testing Life Cycle Unit-3Software Testing Life Cycle Unit-3
Software Testing Life Cycle Unit-3Raj vardhan
 
Internet Basics Unit-7
Internet Basics  Unit-7Internet Basics  Unit-7
Internet Basics Unit-7Raj vardhan
 
Local Area Network – Wired LAN
Local Area Network – Wired LANLocal Area Network – Wired LAN
Local Area Network – Wired LANRaj vardhan
 
Network Connecting Devices UNIT 5
Network Connecting Devices UNIT 5Network Connecting Devices UNIT 5
Network Connecting Devices UNIT 5Raj vardhan
 
UNIT 4-HEADER FILES IN C
UNIT 4-HEADER FILES IN CUNIT 4-HEADER FILES IN C
UNIT 4-HEADER FILES IN CRaj vardhan
 
Wireless LANs(IEEE802.11) Architecture
Wireless LANs(IEEE802.11) Architecture Wireless LANs(IEEE802.11) Architecture
Wireless LANs(IEEE802.11) Architecture Raj vardhan
 
UNIT -03 Transmission Media and Connecting Devices
UNIT -03 Transmission Media and Connecting Devices UNIT -03 Transmission Media and Connecting Devices
UNIT -03 Transmission Media and Connecting Devices Raj vardhan
 
Unit 1: Introduction to DBMS Unit 1 Complete
Unit 1: Introduction to DBMS Unit 1 CompleteUnit 1: Introduction to DBMS Unit 1 Complete
Unit 1: Introduction to DBMS Unit 1 CompleteRaj vardhan
 
Introduction To Software Concepts Unit 1 & 2
Introduction To Software Concepts Unit 1 & 2Introduction To Software Concepts Unit 1 & 2
Introduction To Software Concepts Unit 1 & 2Raj vardhan
 
Swachh Bharat Abhiyan - Project Report
Swachh Bharat Abhiyan - Project ReportSwachh Bharat Abhiyan - Project Report
Swachh Bharat Abhiyan - Project ReportRaj vardhan
 
Network Topology
Network TopologyNetwork Topology
Network TopologyRaj vardhan
 
Microsoft Office Word Introduction Complete
Microsoft Office Word  Introduction CompleteMicrosoft Office Word  Introduction Complete
Microsoft Office Word Introduction CompleteRaj vardhan
 
Digital money Revolution Introduction
Digital money Revolution IntroductionDigital money Revolution Introduction
Digital money Revolution IntroductionRaj vardhan
 
Definition of Business
Definition of BusinessDefinition of Business
Definition of BusinessRaj vardhan
 
Business Terms & Concepts
Business Terms & ConceptsBusiness Terms & Concepts
Business Terms & ConceptsRaj vardhan
 
Interaction With Computers FIT
Interaction With Computers FITInteraction With Computers FIT
Interaction With Computers FITRaj vardhan
 
FIT-MS-WORD Lab | BCA
FIT-MS-WORD Lab | BCAFIT-MS-WORD Lab | BCA
FIT-MS-WORD Lab | BCARaj vardhan
 
Syllabus Front End Design Tool VB.NET | BCA-205
Syllabus Front End Design Tool VB.NET | BCA-205 Syllabus Front End Design Tool VB.NET | BCA-205
Syllabus Front End Design Tool VB.NET | BCA-205 Raj vardhan
 
UNIT-II VISUAL BASIC.NET | BCA
UNIT-II VISUAL BASIC.NET | BCAUNIT-II VISUAL BASIC.NET | BCA
UNIT-II VISUAL BASIC.NET | BCARaj vardhan
 

Plus de Raj vardhan (20)

Software Testing Life Cycle Unit-3
Software Testing Life Cycle Unit-3Software Testing Life Cycle Unit-3
Software Testing Life Cycle Unit-3
 
Internet Basics Unit-7
Internet Basics  Unit-7Internet Basics  Unit-7
Internet Basics Unit-7
 
Local Area Network – Wired LAN
Local Area Network – Wired LANLocal Area Network – Wired LAN
Local Area Network – Wired LAN
 
Network Connecting Devices UNIT 5
Network Connecting Devices UNIT 5Network Connecting Devices UNIT 5
Network Connecting Devices UNIT 5
 
UNIT 4-HEADER FILES IN C
UNIT 4-HEADER FILES IN CUNIT 4-HEADER FILES IN C
UNIT 4-HEADER FILES IN C
 
Wireless LANs(IEEE802.11) Architecture
Wireless LANs(IEEE802.11) Architecture Wireless LANs(IEEE802.11) Architecture
Wireless LANs(IEEE802.11) Architecture
 
UNIT -03 Transmission Media and Connecting Devices
UNIT -03 Transmission Media and Connecting Devices UNIT -03 Transmission Media and Connecting Devices
UNIT -03 Transmission Media and Connecting Devices
 
Unit 1: Introduction to DBMS Unit 1 Complete
Unit 1: Introduction to DBMS Unit 1 CompleteUnit 1: Introduction to DBMS Unit 1 Complete
Unit 1: Introduction to DBMS Unit 1 Complete
 
Introduction To Software Concepts Unit 1 & 2
Introduction To Software Concepts Unit 1 & 2Introduction To Software Concepts Unit 1 & 2
Introduction To Software Concepts Unit 1 & 2
 
Swachh Bharat Abhiyan - Project Report
Swachh Bharat Abhiyan - Project ReportSwachh Bharat Abhiyan - Project Report
Swachh Bharat Abhiyan - Project Report
 
Network Topology
Network TopologyNetwork Topology
Network Topology
 
Microsoft Office Word Introduction Complete
Microsoft Office Word  Introduction CompleteMicrosoft Office Word  Introduction Complete
Microsoft Office Word Introduction Complete
 
Digital money Revolution Introduction
Digital money Revolution IntroductionDigital money Revolution Introduction
Digital money Revolution Introduction
 
C Programming
C ProgrammingC Programming
C Programming
 
Definition of Business
Definition of BusinessDefinition of Business
Definition of Business
 
Business Terms & Concepts
Business Terms & ConceptsBusiness Terms & Concepts
Business Terms & Concepts
 
Interaction With Computers FIT
Interaction With Computers FITInteraction With Computers FIT
Interaction With Computers FIT
 
FIT-MS-WORD Lab | BCA
FIT-MS-WORD Lab | BCAFIT-MS-WORD Lab | BCA
FIT-MS-WORD Lab | BCA
 
Syllabus Front End Design Tool VB.NET | BCA-205
Syllabus Front End Design Tool VB.NET | BCA-205 Syllabus Front End Design Tool VB.NET | BCA-205
Syllabus Front End Design Tool VB.NET | BCA-205
 
UNIT-II VISUAL BASIC.NET | BCA
UNIT-II VISUAL BASIC.NET | BCAUNIT-II VISUAL BASIC.NET | BCA
UNIT-II VISUAL BASIC.NET | BCA
 

Dernier

Micromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of PowdersMicromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of PowdersChitralekhaTherkar
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
PSYCHIATRIC History collection FORMAT.pptx
PSYCHIATRIC   History collection FORMAT.pptxPSYCHIATRIC   History collection FORMAT.pptx
PSYCHIATRIC History collection FORMAT.pptxPoojaSen20
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxRoyAbrique
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 

Dernier (20)

Micromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of PowdersMicromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of Powders
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
PSYCHIATRIC History collection FORMAT.pptx
PSYCHIATRIC   History collection FORMAT.pptxPSYCHIATRIC   History collection FORMAT.pptx
PSYCHIATRIC History collection FORMAT.pptx
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSDStaff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 

CS221: Guide to Number Systems

  • 1. CS221: Digital Design Number SystemNumber System Dr. A. Sahu Dept of Comp. Sc. & Engg.Dept of Comp. Sc. & Engg. Indian Institute of Technology Guwahati 1
  • 2. OutlineOutline • Number System D i l Bi O t l H– Decimal, Binary, Octal, Hex • Conversion (one to another) – Decimal to Binary Octal Hex & Vice VersaDecimal to Binary, Octal, Hex   & Vice Versa – Binary to HEX & vice versa • Other representation – Signed, Unsigned, Complement • Operation – Add, Sub, Mul, Div, Mod • How to handle real number efficiently  ? Float Double– Float, Double 2
  • 3. What Digit? => Number SystemWhat Digit?   > Number System  • Famous Number System: Dec Rom BinFamous Number System: Dec, Rom, Bin • Decimal System: 0 ‐9 M l b h h 10 fi– May evolves: because human have 10 finger  • Roman System – May evolves to make easy to look and feel – Pre/Post Concept: (IV,  V  & VI) is (5‐1, 5 & 5+1)  • Binary System, Others (Oct, Hex) – One can cut an apple in to twopp 3
  • 4. Significant DigitsSignificant Digits Binary: 11101101Binary: 11101101 Most significant digit Least significant digitMost significant digit                   Least significant digit Decimal: 1063079Decimal:  1063079 Most significant digit Least significant digitMost significant digit                   Least significant digit
  • 5. Decimal (base 10)Decimal (base 10) • Uses positional representationUses positional representation • Each digit corresponds to a power of 10 based  on its position in the numberon its position in the number • The powers of 10 increment from 0, 1, 2, etc.  i h l fas you move right to left – 1,479 = 1 * 103 + 4 * 102 + 7 * 101 + 9 * 100
  • 6. Binary (base 2)Binary (base 2)  • Two digits: 0, 1 • To make the binary numbers more y readable, the digits are often put in groups  of 4 – 1010 = 1 * 23 + 0 * 22 + 1 * 21 + 0 * 20  = 8 + 2  = 10= 10  – 1100 1001 = 1 * 27 + 1 * 26 + 1 * 23 + 1 * 20  = 128 + 64 + 8 + 1 128   64   8   1  = 201
  • 7. How to Encode Numbers: Binary  NumbersNumbers • Working with binary numbers In base ten helps to know powers of 10–In base ten, helps to know powers of 10 • one, ten, hundred, thousand, ten thousand, ... I b t h l t k f 2–In base two, helps to know powers of 2 • one, two, four, eight, sixteen, thirty two, sixty  f h d d t t i htfour, one hundred twenty eight • Count up by powers of two 24 23 22 21 2029 28 27 26 25 a 16 8 4 2 1512 256 128 64 32
  • 8. Octal (base 8)Octal (base 8) • Shorter & easier to read than binary • 8 digits: 0, 1, 2, 3, 4, 5, 6, 7,  • Octal numbersOctal numbers 1368 = 1 * 82 + 3 * 81 + 6 * 80  1 * 64 3 * 8 6 * 1= 1 * 64 + 3 * 8 +  6 * 1 = 9410
  • 9. Hexadecimal (base 16)Hexadecimal (base 16) • Shorter & easier to read than binary • 16 digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F • “0x” often precedes hexadecimal numbers0x  often precedes hexadecimal numbers 0x123 = 1 * 162 + 2 * 161 + 3 * 160  1 * 256 2 * 16 3 * 1= 1 * 256 + 2 * 16 +  3 * 1 = 256 + 32 +  3 = 291 
  • 10. Counting Decimal Binary Octal Hexadecimal 0 00000 0 0 Counting 1 00001 1 1 2 00010 2 2 3 00011 3 3 4 00100 4 4 5 00101 5 5 6 00110 6 66 00110 6 6 7 00111 7 7 8 01000 10 8 9 01001 11 9 10 01010 12 A 11 01011 13 B 12 01100 14 C 13 01101 15 D 14 01110 16 E14 01110 16 E 15 01111 17 F 16 10000 20 10 10
  • 11. Fractional NumberFractional Number  • Point: Decimal Point, Binary Point, Hexadecimal  point • Decimal 247.75   = 2x102+4x101+7x100+7x10‐1+5x10‐2 • BinaryBinary 10.101= 1x21+0x20+1x2‐1+0x2‐2+1x2‐3 • Hexadecimal• Hexadecimal 6A.7D=6x161+10x160+7x16‐1+Dx16‐2
  • 12. Converting To and From DecimalConverting To and From Decimal Successive  Division Weighted  M lti li ti Decimal100 1 2 3 4 5 6 7 8 9 Weighted  Multiplication Successive  Division Multiplication Successive  Di i i Weighted  M lti li ti Octal8 0 1 2 3 4 5 6 7 Hexadecimal16 0 1 2 3 4 5 6 7 8 9 A B C D E F Division Multiplication BinaryBinary2 0 1 12
  • 13. Decimal ↔ BinaryDecimal ↔ Binary SuccessiveSuccessive Division a) Divide the decimal number by 2; the remainder is the LSB of the binary) y ; y number. b) If the quotation is zero, the conversion is complete. Otherwise repeat step  (a) using the quotation as the decimal number. The new remainder is the ( ) g q next most significant bit of the binary number. Weighted a) Multiply each bit of the binary number by its corresponding bit‐ Multiplication weighting factor (i.e., Bit‐0→20=1; Bit‐1→21=2; Bit‐2→22=4; etc).  b) Sum up all of the products in step (a) to get the decimal number.  
  • 14. Decimal  to Binary : Subtraction Methody • Goal Desired decimal number: 12 – Good for human – Get the binary weights to  dd t th d i l Desired decimal number: 12 1 =32 12481632 add up to the decimal  quantity • Work from left to right 12481632 too much 12481632 0 =16 too much 1 • (Right to left – may fill in 1s  that shouldn’t have been  there – try it).  a 12481632 0 =8 ok, keep going 0 1 12481632 0 =8+4=12 DONE 0 1 1 0 0 1 1 0 0 12481632 0 answer0 1 1 0 0
  • 15. Decimal to Binary : Division Methody • Good for computer:  Divide decimal number by 2 and  insert remainder into new binary number.y – Continue dividing quotient by 2 until the quotient is 0. • Example: Convert decimal number 12 to binary 12 div 2  =   ( Quo=6 , Rem=0)   LSB ( )6 div 2  =    (Quo=3, Rem=0) 3 div 2  =     (Quo=1,Rem=1) 1 div 2 = ( Quo=0 Rem=1) MSB1 div 2  =   ( Quo=0, Rem=1)   MSB  1210= 1 1 00 21210  1 1 00 2 
  • 16. Conversion Process Decimal ↔ BaseNN SuccessiveSuccessive Division a) Divide the decimal number by N; the remainder is the LSB of the ANY ) y ; BASE Number . b) If the quotient is zero, the conversion is complete. Otherwise repeat  step (a) using the quotient as the decimal number.  The new remainder p ( ) g q is the next most significant bit of the ANY BASE number. Weighted a) Multiply each bit of the ANY BASE number by its corresponding bit‐ Multiplication weighting factor (i.e., Bit‐0→N0; Bit‐1→N1; Bit‐2→N2; etc).  b) Sum up all of the products in step (a) to get the decimal number.  
  • 17. Decimal ↔ Octal ConversionDecimal ↔ Octal Conversion The Process: Successive Division • Divide  number by 8;  R is the LSB of the octal number  • While Q is 0  • Using the Q as the decimal number.  • New remainder is MSB of the octal number. LSB6r 11 948 ←= 3r 1 118 = 9410 = 1368 MSB1r 0 18 ←= 17
  • 18. Decimal ↔ Hexadecimal ConversionDecimal ↔ Hexadecimal Conversion The Process: Successive Division • Divide  number by 16;  R is the LSB of the hex number  • While Q is 0  • Using the Q as the decimal number.   • New remainder is MSB of the hex number. S 5 MSB5 0 516 LSBEr9416 ←= 9410 = 5E16 MSB5r516 ←=
  • 19. Example: Hex → OctalExample: Hex → Octal Example: C h h d i l b 5A i i l i lConvert the hexadecimal number 5AH into its octal equivalent. Solution: First convert the hexadecimal number into its decimal equivalent then 5 A First convert the hexadecimal number into its decimal equivalent, then  convert the decimal number into its octal equivalent. LSB2r 11 908 ←=5 A 16 1 16 0 16 1 3r 1 118 LSB2r908 = ←= 16 1 80 + 10 = 9010 MSB1r 0 18 ←= ∴ 5AH = 1328 19
  • 20. Example: Octal → BinaryExample: Octal → Binary Example: Convert the octal number 132 into its binary equivalentConvert the octal number 1328 into its binary equivalent. Solution: First convert the octal number into its decimal equivalent, then convert the  d l b b l 1 3 2 22 LSB0r 45 902 ←= decimal number into its binary equivalent. 1328 = 10110102 82 81 80 64 8 1 5 0r 11 222 1r 22 452 = = 64 + 24 + 2 = 9010 1 1r 2 52 1r 5 112 = = MSB1r 0 12 0r 1 22 ←= = 20
  • 21. Binary ↔ Octal ↔ Hex ShortcutBinary ↔ Octal ↔ Hex Shortcut • Relation Bi l d h b• Binary, octal, and hex number systems  • All powers of two • Exploit (This Relation)  •Make conversion easier. 21
  • 22. Substitution Code Convert 0101011010101110011010102 to hex using Substitution Code Convert 0101011010101110011010102 to hex using  the 4‐bit substitution code : 5 6 A E 6 A 0101  0110  1010  1110  0110  1010 56AE6A16
  • 24. Other RepresentationOther Representation  • Signed & Unsigned Number Si d b l bi ( MSB) i i d bi• Signed number last bit (one MSB) is signed bit Assume: 8 bit number  Unsigned 12 :    0000 1100  Signed +12   :    0000 1100    Signed ‐12     :   1000 1100    • Complement numberp Unsigned  binary   12   = 00001100 1’s Complement of 12 = 1111 00111 s Complement of 12 = 1111 0011 24