SlideShare a Scribd company logo
CSE370, Lecture 2
Lecture 2: Number Systems
 Logistics
 Webpage is up! http://www.cs.washington.edu/370
 HW1 is posted on the web in the calender --- due 10/1 10:30am
 Third TA: Tony Chick chickt@cs.washington.edu
 Email list: please sign up on the web.
 Lab1 starts next week: sections MTW --- show up to pick up
your lab kit
 Last lecture
 Class introduction and overview
 Today
 Binary numbers
 Base conversion
 Number systems
 Twos-complement
 A/D and D/A conversion
CSE370, Lecture 2
CSE370, Lecture 2
The “WHY” slide
 Binary numbers
 All computers work with 0’s and 1’s so it is like learning
alphabets before learning English
 Base conversion
 For convenience, people use other bases (like decimal,
hexdecimal) and we need to know how to convert from one to
another.
 Number systems
 There are more than one way to express a number in binary.
So 1010 could be -2, -5 or -6 and need to know which one.
 A/D and D/A conversion
 Real world signals come in continuous/analog format and it is
good to know generally how they become 0’s and 1’s (and visa
versa).
CSE370, Lecture 2
Digital
 Digital = discrete
 Binary codes (example: BCD)
 Decimal digits 0-9
 Binary codes
 Represent symbols using binary
digits (bits)
 Digital computers:
 I/O is digital
 ASCII, decimal, etc.
 Internal representation is binary
 Process information in bits
Decimal
Symbols
0
1
2
3
4
5
6
7
8
9
BCD
Code
0000
0001
0010
0011
0100
0101
0110
0111
1000
1001
CSE370, Lecture 2
The basics: Binary numbers
 Bases we will use
 Binary: Base 2
 Octal: Base 8
 Decimal: Base 10
 Hexadecimal: Base 16
 Positional number system
 1012= 1×22
+ 0×21
+ 1×20
 638 = 6×81
+ 3×80
 A116= 10×161
+ 1×160
 Addition and subtraction
1011
+ 1010
10101
1011
– 0110
0101
CSE370, Lecture 2
Binary → hex/decimal/octal conversion
 Conversion from binary to octal/hex
 Binary: 10011110001
 Octal: 10 | 011 | 110 | 001=23618
 Hex: 100 | 1111 | 0001=4F116
 Conversion from binary to decimal
 1012= 1×22
+ 0×21
+ 1×20
= 510
 63.48 = 6×81
+ 3×80
+ 4×8–1
= 51.510
 A116= 10×161
+ 1×160
= 16110
CSE370, Lecture 2
Decimal→ binary/octal/hex conversion
 Why does this work?
 N=5610=1110002
 Q=N/2=56/2=111000/2=11100 remainder 0
 Each successive divide liberates an LSB (least
significant bit)
CSE370, Lecture 2
Number systems
 How do we write negative binary numbers?
 Historically: 3 approaches
 Sign-and-magnitude
 Ones-complement
 Twos-complement
 For all 3, the most-significant bit (MSB) is the sign
digit
 0 ≡ positive
 1 ≡ negative
 twos-complement is the important one
 Simplifies arithmetic
 Used almost universally
CSE370, Lecture 2
Sign-and-magnitude
 The most-significant bit (MSB) is the sign digit
 0 ≡ positive
 1 ≡ negative
 The remaining bits are the number’s magnitude
 Problem 1: Two representations for zero
 0 = 0000 and also –0 = 1000
 Problem 2: Arithmetic is cumbersome
CSE370, Lecture 2
Ones-complement
 Negative number: Bitwise complement positive number
 0011 ≡ 310
 1100 ≡ –310
 Solves the arithmetic problem
 Remaining problem: Two representations for zero
 0 = 0000 and also –0 = 1111
CSE370, Lecture 2
Twos-complement
 Negative number: Bitwise complement plus one
 0011 ≡ 310
 1101 ≡ –310
 Number wheel
0000
0001
0011
1111
1110
1100
1011
1010
1000 0111
0110
0100
0010
0101
1001
1101
0
+ 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
– 8
– 7
– 6
– 5
– 4
– 3
– 2
– 1
 Only one zero!
 MSB is the sign digit
 0 ≡ positive
 1 ≡ negative
CSE370, Lecture 2
Twos-complement (con’t)
 Complementing a complement  the original number
 Arithmetic is easy
 Subtraction = negation and addition
 Easy to implement in hardware
CSE370, Lecture 2
Miscellaneous
 Twos-complement of non-integers
 1.687510 = 01.10112
 –1.687510 = 10.01012
 Sign extension
 Write +6 and –6 as twos complement
 0110 and 1010
 Sign extend to 8-bit bytes
 00000110 and 11111010
 Can’t infer a representation from a number
 11001 is 25 (unsigned)
 11001 is –9 (sign magnitude)
 11001 is –6 (ones complement)
 11001 is –7 (twos complement)
CSE370, Lecture 2
Twos-complement overflow
 Summing two positive numbers gives a negative result
 Summing two negative numbers gives a positive result
 Make sure to have enough bits to handle overflow
0000
0001
0011
1111
1110
1100
1011
1010
1000 0111
0110
0100
0010
0101
1001
1101
0
+ 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
– 8
– 7
– 6
– 5
– 4
– 3
– 2
– 1
0000
0001
0011
1111
1110
1100
1011
1010
1000 0111
0110
0100
0010
0101
1001
1101
0
+ 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
– 8
– 7
– 6
– 5
– 4
– 3
– 2
– 1
6 + 4 ⇒ –6 –7 – 3 ⇒ +6
CSE370, Lecture 2
Gray and BCD codes
Decimal
Symbols
0
1
2
3
4
5
6
7
8
9
BCD
Code
0000
0001
0010
0011
0100
0101
0110
0111
1000
1001
Decimal
Symbols
0
1
2
3
4
5
6
7
8
9
Gray
Code
0000
0001
0011
0010
0110
0111
0101
0100
1100
1101
CSE370, Lecture 2
The physical world is analog
 Digital systems need to
 Measure analog quantities
 Speech waveforms, etc
 Control analog systems
 Drive motors, etc
 How do we connect the analog and digital domains?
 Analog-to-digital converter (A/D)
 Example: CD recording
 Digital-to-analog converter (D/A)
 Example: CD playback
CSE370, Lecture 2
Sampling
 Quantization
 Conversion from analog
to discrete values
 Quantizing a signal
 We sample it
Datel Data Acquisition and
Conversion Handbook
CSE370, Lecture 2
Conversion
 Encoding
 Assigning a digital word to
each discrete value
 Encoding a quantized
signal
 Encode the samples
 Typically Gray or binary
codes
Datel Data Acquisition and
Conversion Handbook

More Related Content

Similar to Lec2_NumberSystems.ppt

Lec 02
Lec 02Lec 02
Lec 02
Syed Haider
 
Number system
Number systemNumber system
Number system
Iqra Yasin
 
ch3a-binary-numbers.ppt
ch3a-binary-numbers.pptch3a-binary-numbers.ppt
ch3a-binary-numbers.ppt
RabiaAsif31
 
Number system
Number systemNumber system
Number system
mabroukamohammed
 
ch3a-binary-numbers.ppt
ch3a-binary-numbers.pptch3a-binary-numbers.ppt
ch3a-binary-numbers.ppt
MUNAZARAZZAQELEA
 
Chapter 02 Data Types
Chapter 02   Data TypesChapter 02   Data Types
Chapter 02 Data Types
Nathan Yeung
 
ch3a-binary-numbers.ppt
ch3a-binary-numbers.pptch3a-binary-numbers.ppt
ch3a-binary-numbers.ppt
Suganthi Vasanth Raj
 
ch3a-binary-numbers.ppt
ch3a-binary-numbers.pptch3a-binary-numbers.ppt
ch3a-binary-numbers.ppt
ssuser52a19e
 
Review on Number Systems: Decimal, Binary, and Hexadecimal
Review on Number Systems: Decimal, Binary, and HexadecimalReview on Number Systems: Decimal, Binary, and Hexadecimal
Review on Number Systems: Decimal, Binary, and Hexadecimal
UtkirjonUbaydullaev1
 
ch3a-binary-numbers.ppt
ch3a-binary-numbers.pptch3a-binary-numbers.ppt
ch3a-binary-numbers.ppt
RAJKUMARP63
 
binary-numbers.ppt
binary-numbers.pptbinary-numbers.ppt
binary-numbers.ppt
MarlonMagtibay2
 
NumberSystemsAnnotated.pdf
NumberSystemsAnnotated.pdfNumberSystemsAnnotated.pdf
NumberSystemsAnnotated.pdf
MarzCasipong1
 
Number system
Number systemNumber system
Number system
aviban
 
Number system
Number systemNumber system
Number system
Mantra VLSI
 
Binary octal
Binary octalBinary octal
Binary octal
drdipo4
 
Module 1 number systems and code1
Module 1  number systems and code1Module 1  number systems and code1
Module 1 number systems and code1
Deepak John
 
Course Name: Digital System Design Number System.pdf
Course Name: Digital System Design Number System.pdfCourse Name: Digital System Design Number System.pdf
Course Name: Digital System Design Number System.pdf
MdJubayerFaisalEmon
 
Number Systems
Number SystemsNumber Systems
Number Systems
Infinity Tech Solutions
 
Number System and Conversions.pptx
Number System and Conversions.pptxNumber System and Conversions.pptx
Number System and Conversions.pptx
khalidkk6
 
Logic Design - Chapter 1: Number Systems and Codes
Logic Design - Chapter 1: Number Systems and CodesLogic Design - Chapter 1: Number Systems and Codes
Logic Design - Chapter 1: Number Systems and Codes
Gouda Mando
 

Similar to Lec2_NumberSystems.ppt (20)

Lec 02
Lec 02Lec 02
Lec 02
 
Number system
Number systemNumber system
Number system
 
ch3a-binary-numbers.ppt
ch3a-binary-numbers.pptch3a-binary-numbers.ppt
ch3a-binary-numbers.ppt
 
Number system
Number systemNumber system
Number system
 
ch3a-binary-numbers.ppt
ch3a-binary-numbers.pptch3a-binary-numbers.ppt
ch3a-binary-numbers.ppt
 
Chapter 02 Data Types
Chapter 02   Data TypesChapter 02   Data Types
Chapter 02 Data Types
 
ch3a-binary-numbers.ppt
ch3a-binary-numbers.pptch3a-binary-numbers.ppt
ch3a-binary-numbers.ppt
 
ch3a-binary-numbers.ppt
ch3a-binary-numbers.pptch3a-binary-numbers.ppt
ch3a-binary-numbers.ppt
 
Review on Number Systems: Decimal, Binary, and Hexadecimal
Review on Number Systems: Decimal, Binary, and HexadecimalReview on Number Systems: Decimal, Binary, and Hexadecimal
Review on Number Systems: Decimal, Binary, and Hexadecimal
 
ch3a-binary-numbers.ppt
ch3a-binary-numbers.pptch3a-binary-numbers.ppt
ch3a-binary-numbers.ppt
 
binary-numbers.ppt
binary-numbers.pptbinary-numbers.ppt
binary-numbers.ppt
 
NumberSystemsAnnotated.pdf
NumberSystemsAnnotated.pdfNumberSystemsAnnotated.pdf
NumberSystemsAnnotated.pdf
 
Number system
Number systemNumber system
Number system
 
Number system
Number systemNumber system
Number system
 
Binary octal
Binary octalBinary octal
Binary octal
 
Module 1 number systems and code1
Module 1  number systems and code1Module 1  number systems and code1
Module 1 number systems and code1
 
Course Name: Digital System Design Number System.pdf
Course Name: Digital System Design Number System.pdfCourse Name: Digital System Design Number System.pdf
Course Name: Digital System Design Number System.pdf
 
Number Systems
Number SystemsNumber Systems
Number Systems
 
Number System and Conversions.pptx
Number System and Conversions.pptxNumber System and Conversions.pptx
Number System and Conversions.pptx
 
Logic Design - Chapter 1: Number Systems and Codes
Logic Design - Chapter 1: Number Systems and CodesLogic Design - Chapter 1: Number Systems and Codes
Logic Design - Chapter 1: Number Systems and Codes
 

More from MarlonMagtibay2

informationmanagement-130518152950-phpapp01.pptx
informationmanagement-130518152950-phpapp01.pptxinformationmanagement-130518152950-phpapp01.pptx
informationmanagement-130518152950-phpapp01.pptx
MarlonMagtibay2
 
chapter8-stack-161018120225.pdf
chapter8-stack-161018120225.pdfchapter8-stack-161018120225.pdf
chapter8-stack-161018120225.pdf
MarlonMagtibay2
 
arrays-130116232821-phpapp02.pdf
arrays-130116232821-phpapp02.pdfarrays-130116232821-phpapp02.pdf
arrays-130116232821-phpapp02.pdf
MarlonMagtibay2
 
CS4961-L1.ppt
CS4961-L1.pptCS4961-L1.ppt
CS4961-L1.ppt
MarlonMagtibay2
 
CS4961-L9.ppt
CS4961-L9.pptCS4961-L9.ppt
CS4961-L9.ppt
MarlonMagtibay2
 
Data Structure - Stack.pptx
Data Structure - Stack.pptxData Structure - Stack.pptx
Data Structure - Stack.pptx
MarlonMagtibay2
 
Lecture_Computer_Codes.ppt
Lecture_Computer_Codes.pptLecture_Computer_Codes.ppt
Lecture_Computer_Codes.ppt
MarlonMagtibay2
 
lecture3_dec_bin_1.ppt
lecture3_dec_bin_1.pptlecture3_dec_bin_1.ppt
lecture3_dec_bin_1.ppt
MarlonMagtibay2
 
Arithmetic.ppt
Arithmetic.pptArithmetic.ppt
Arithmetic.ppt
MarlonMagtibay2
 
01.NumberSystems.ppt
01.NumberSystems.ppt01.NumberSystems.ppt
01.NumberSystems.ppt
MarlonMagtibay2
 
lect1.ppt
lect1.pptlect1.ppt
lect1.ppt
MarlonMagtibay2
 
renewablle energy.ppt
renewablle energy.pptrenewablle energy.ppt
renewablle energy.ppt
MarlonMagtibay2
 
ch04.ppt
ch04.pptch04.ppt
ch04.ppt
MarlonMagtibay2
 
lecture01_Introduction.pdf
lecture01_Introduction.pdflecture01_Introduction.pdf
lecture01_Introduction.pdf
MarlonMagtibay2
 

More from MarlonMagtibay2 (14)

informationmanagement-130518152950-phpapp01.pptx
informationmanagement-130518152950-phpapp01.pptxinformationmanagement-130518152950-phpapp01.pptx
informationmanagement-130518152950-phpapp01.pptx
 
chapter8-stack-161018120225.pdf
chapter8-stack-161018120225.pdfchapter8-stack-161018120225.pdf
chapter8-stack-161018120225.pdf
 
arrays-130116232821-phpapp02.pdf
arrays-130116232821-phpapp02.pdfarrays-130116232821-phpapp02.pdf
arrays-130116232821-phpapp02.pdf
 
CS4961-L1.ppt
CS4961-L1.pptCS4961-L1.ppt
CS4961-L1.ppt
 
CS4961-L9.ppt
CS4961-L9.pptCS4961-L9.ppt
CS4961-L9.ppt
 
Data Structure - Stack.pptx
Data Structure - Stack.pptxData Structure - Stack.pptx
Data Structure - Stack.pptx
 
Lecture_Computer_Codes.ppt
Lecture_Computer_Codes.pptLecture_Computer_Codes.ppt
Lecture_Computer_Codes.ppt
 
lecture3_dec_bin_1.ppt
lecture3_dec_bin_1.pptlecture3_dec_bin_1.ppt
lecture3_dec_bin_1.ppt
 
Arithmetic.ppt
Arithmetic.pptArithmetic.ppt
Arithmetic.ppt
 
01.NumberSystems.ppt
01.NumberSystems.ppt01.NumberSystems.ppt
01.NumberSystems.ppt
 
lect1.ppt
lect1.pptlect1.ppt
lect1.ppt
 
renewablle energy.ppt
renewablle energy.pptrenewablle energy.ppt
renewablle energy.ppt
 
ch04.ppt
ch04.pptch04.ppt
ch04.ppt
 
lecture01_Introduction.pdf
lecture01_Introduction.pdflecture01_Introduction.pdf
lecture01_Introduction.pdf
 

Recently uploaded

socradar-q1-2024-aviation-industry-report.pdf
socradar-q1-2024-aviation-industry-report.pdfsocradar-q1-2024-aviation-industry-report.pdf
socradar-q1-2024-aviation-industry-report.pdf
SOCRadar
 
Fundamentals of Programming and Language Processors
Fundamentals of Programming and Language ProcessorsFundamentals of Programming and Language Processors
Fundamentals of Programming and Language Processors
Rakesh Kumar R
 
Unveiling the Advantages of Agile Software Development.pdf
Unveiling the Advantages of Agile Software Development.pdfUnveiling the Advantages of Agile Software Development.pdf
Unveiling the Advantages of Agile Software Development.pdf
brainerhub1
 
Hand Rolled Applicative User Validation Code Kata
Hand Rolled Applicative User ValidationCode KataHand Rolled Applicative User ValidationCode Kata
Hand Rolled Applicative User Validation Code Kata
Philip Schwarz
 
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Łukasz Chruściel
 
在线购买加拿大英属哥伦比亚大学毕业证本科学位证书原版一模一样
在线购买加拿大英属哥伦比亚大学毕业证本科学位证书原版一模一样在线购买加拿大英属哥伦比亚大学毕业证本科学位证书原版一模一样
在线购买加拿大英属哥伦比亚大学毕业证本科学位证书原版一模一样
mz5nrf0n
 
Energy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina JonuziEnergy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina Jonuzi
Green Software Development
 
E-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet DynamicsE-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet Dynamics
Hornet Dynamics
 
E-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian Companies
E-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian CompaniesE-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian Companies
E-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian Companies
Quickdice ERP
 
zOS Mainframe JES2-JES3 JCL-JECL Differences
zOS Mainframe JES2-JES3 JCL-JECL DifferenceszOS Mainframe JES2-JES3 JCL-JECL Differences
zOS Mainframe JES2-JES3 JCL-JECL Differences
YousufSait3
 
Requirement Traceability in Xen Functional Safety
Requirement Traceability in Xen Functional SafetyRequirement Traceability in Xen Functional Safety
Requirement Traceability in Xen Functional Safety
Ayan Halder
 
Top Benefits of Using Salesforce Healthcare CRM for Patient Management.pdf
Top Benefits of Using Salesforce Healthcare CRM for Patient Management.pdfTop Benefits of Using Salesforce Healthcare CRM for Patient Management.pdf
Top Benefits of Using Salesforce Healthcare CRM for Patient Management.pdf
VALiNTRY360
 
Lecture 2 - software testing SE 412.pptx
Lecture 2 - software testing SE 412.pptxLecture 2 - software testing SE 412.pptx
Lecture 2 - software testing SE 412.pptx
TaghreedAltamimi
 
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
Łukasz Chruściel
 
UI5con 2024 - Bring Your Own Design System
UI5con 2024 - Bring Your Own Design SystemUI5con 2024 - Bring Your Own Design System
UI5con 2024 - Bring Your Own Design System
Peter Muessig
 
Oracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptxOracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptx
Remote DBA Services
 
Enums On Steroids - let's look at sealed classes !
Enums On Steroids - let's look at sealed classes !Enums On Steroids - let's look at sealed classes !
Enums On Steroids - let's look at sealed classes !
Marcin Chrost
 
Mobile app Development Services | Drona Infotech
Mobile app Development Services  | Drona InfotechMobile app Development Services  | Drona Infotech
Mobile app Development Services | Drona Infotech
Drona Infotech
 
UI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
UI5con 2024 - Keynote: Latest News about UI5 and it’s EcosystemUI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
UI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
Peter Muessig
 
8 Best Automated Android App Testing Tool and Framework in 2024.pdf
8 Best Automated Android App Testing Tool and Framework in 2024.pdf8 Best Automated Android App Testing Tool and Framework in 2024.pdf
8 Best Automated Android App Testing Tool and Framework in 2024.pdf
kalichargn70th171
 

Recently uploaded (20)

socradar-q1-2024-aviation-industry-report.pdf
socradar-q1-2024-aviation-industry-report.pdfsocradar-q1-2024-aviation-industry-report.pdf
socradar-q1-2024-aviation-industry-report.pdf
 
Fundamentals of Programming and Language Processors
Fundamentals of Programming and Language ProcessorsFundamentals of Programming and Language Processors
Fundamentals of Programming and Language Processors
 
Unveiling the Advantages of Agile Software Development.pdf
Unveiling the Advantages of Agile Software Development.pdfUnveiling the Advantages of Agile Software Development.pdf
Unveiling the Advantages of Agile Software Development.pdf
 
Hand Rolled Applicative User Validation Code Kata
Hand Rolled Applicative User ValidationCode KataHand Rolled Applicative User ValidationCode Kata
Hand Rolled Applicative User Validation Code Kata
 
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
 
在线购买加拿大英属哥伦比亚大学毕业证本科学位证书原版一模一样
在线购买加拿大英属哥伦比亚大学毕业证本科学位证书原版一模一样在线购买加拿大英属哥伦比亚大学毕业证本科学位证书原版一模一样
在线购买加拿大英属哥伦比亚大学毕业证本科学位证书原版一模一样
 
Energy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina JonuziEnergy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina Jonuzi
 
E-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet DynamicsE-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet Dynamics
 
E-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian Companies
E-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian CompaniesE-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian Companies
E-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian Companies
 
zOS Mainframe JES2-JES3 JCL-JECL Differences
zOS Mainframe JES2-JES3 JCL-JECL DifferenceszOS Mainframe JES2-JES3 JCL-JECL Differences
zOS Mainframe JES2-JES3 JCL-JECL Differences
 
Requirement Traceability in Xen Functional Safety
Requirement Traceability in Xen Functional SafetyRequirement Traceability in Xen Functional Safety
Requirement Traceability in Xen Functional Safety
 
Top Benefits of Using Salesforce Healthcare CRM for Patient Management.pdf
Top Benefits of Using Salesforce Healthcare CRM for Patient Management.pdfTop Benefits of Using Salesforce Healthcare CRM for Patient Management.pdf
Top Benefits of Using Salesforce Healthcare CRM for Patient Management.pdf
 
Lecture 2 - software testing SE 412.pptx
Lecture 2 - software testing SE 412.pptxLecture 2 - software testing SE 412.pptx
Lecture 2 - software testing SE 412.pptx
 
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
 
UI5con 2024 - Bring Your Own Design System
UI5con 2024 - Bring Your Own Design SystemUI5con 2024 - Bring Your Own Design System
UI5con 2024 - Bring Your Own Design System
 
Oracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptxOracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptx
 
Enums On Steroids - let's look at sealed classes !
Enums On Steroids - let's look at sealed classes !Enums On Steroids - let's look at sealed classes !
Enums On Steroids - let's look at sealed classes !
 
Mobile app Development Services | Drona Infotech
Mobile app Development Services  | Drona InfotechMobile app Development Services  | Drona Infotech
Mobile app Development Services | Drona Infotech
 
UI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
UI5con 2024 - Keynote: Latest News about UI5 and it’s EcosystemUI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
UI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
 
8 Best Automated Android App Testing Tool and Framework in 2024.pdf
8 Best Automated Android App Testing Tool and Framework in 2024.pdf8 Best Automated Android App Testing Tool and Framework in 2024.pdf
8 Best Automated Android App Testing Tool and Framework in 2024.pdf
 

Lec2_NumberSystems.ppt

  • 1. CSE370, Lecture 2 Lecture 2: Number Systems  Logistics  Webpage is up! http://www.cs.washington.edu/370  HW1 is posted on the web in the calender --- due 10/1 10:30am  Third TA: Tony Chick chickt@cs.washington.edu  Email list: please sign up on the web.  Lab1 starts next week: sections MTW --- show up to pick up your lab kit  Last lecture  Class introduction and overview  Today  Binary numbers  Base conversion  Number systems  Twos-complement  A/D and D/A conversion
  • 3. CSE370, Lecture 2 The “WHY” slide  Binary numbers  All computers work with 0’s and 1’s so it is like learning alphabets before learning English  Base conversion  For convenience, people use other bases (like decimal, hexdecimal) and we need to know how to convert from one to another.  Number systems  There are more than one way to express a number in binary. So 1010 could be -2, -5 or -6 and need to know which one.  A/D and D/A conversion  Real world signals come in continuous/analog format and it is good to know generally how they become 0’s and 1’s (and visa versa).
  • 4. CSE370, Lecture 2 Digital  Digital = discrete  Binary codes (example: BCD)  Decimal digits 0-9  Binary codes  Represent symbols using binary digits (bits)  Digital computers:  I/O is digital  ASCII, decimal, etc.  Internal representation is binary  Process information in bits Decimal Symbols 0 1 2 3 4 5 6 7 8 9 BCD Code 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001
  • 5. CSE370, Lecture 2 The basics: Binary numbers  Bases we will use  Binary: Base 2  Octal: Base 8  Decimal: Base 10  Hexadecimal: Base 16  Positional number system  1012= 1×22 + 0×21 + 1×20  638 = 6×81 + 3×80  A116= 10×161 + 1×160  Addition and subtraction 1011 + 1010 10101 1011 – 0110 0101
  • 6. CSE370, Lecture 2 Binary → hex/decimal/octal conversion  Conversion from binary to octal/hex  Binary: 10011110001  Octal: 10 | 011 | 110 | 001=23618  Hex: 100 | 1111 | 0001=4F116  Conversion from binary to decimal  1012= 1×22 + 0×21 + 1×20 = 510  63.48 = 6×81 + 3×80 + 4×8–1 = 51.510  A116= 10×161 + 1×160 = 16110
  • 7. CSE370, Lecture 2 Decimal→ binary/octal/hex conversion  Why does this work?  N=5610=1110002  Q=N/2=56/2=111000/2=11100 remainder 0  Each successive divide liberates an LSB (least significant bit)
  • 8. CSE370, Lecture 2 Number systems  How do we write negative binary numbers?  Historically: 3 approaches  Sign-and-magnitude  Ones-complement  Twos-complement  For all 3, the most-significant bit (MSB) is the sign digit  0 ≡ positive  1 ≡ negative  twos-complement is the important one  Simplifies arithmetic  Used almost universally
  • 9. CSE370, Lecture 2 Sign-and-magnitude  The most-significant bit (MSB) is the sign digit  0 ≡ positive  1 ≡ negative  The remaining bits are the number’s magnitude  Problem 1: Two representations for zero  0 = 0000 and also –0 = 1000  Problem 2: Arithmetic is cumbersome
  • 10. CSE370, Lecture 2 Ones-complement  Negative number: Bitwise complement positive number  0011 ≡ 310  1100 ≡ –310  Solves the arithmetic problem  Remaining problem: Two representations for zero  0 = 0000 and also –0 = 1111
  • 11. CSE370, Lecture 2 Twos-complement  Negative number: Bitwise complement plus one  0011 ≡ 310  1101 ≡ –310  Number wheel 0000 0001 0011 1111 1110 1100 1011 1010 1000 0111 0110 0100 0010 0101 1001 1101 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 – 8 – 7 – 6 – 5 – 4 – 3 – 2 – 1  Only one zero!  MSB is the sign digit  0 ≡ positive  1 ≡ negative
  • 12. CSE370, Lecture 2 Twos-complement (con’t)  Complementing a complement  the original number  Arithmetic is easy  Subtraction = negation and addition  Easy to implement in hardware
  • 13. CSE370, Lecture 2 Miscellaneous  Twos-complement of non-integers  1.687510 = 01.10112  –1.687510 = 10.01012  Sign extension  Write +6 and –6 as twos complement  0110 and 1010  Sign extend to 8-bit bytes  00000110 and 11111010  Can’t infer a representation from a number  11001 is 25 (unsigned)  11001 is –9 (sign magnitude)  11001 is –6 (ones complement)  11001 is –7 (twos complement)
  • 14. CSE370, Lecture 2 Twos-complement overflow  Summing two positive numbers gives a negative result  Summing two negative numbers gives a positive result  Make sure to have enough bits to handle overflow 0000 0001 0011 1111 1110 1100 1011 1010 1000 0111 0110 0100 0010 0101 1001 1101 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 – 8 – 7 – 6 – 5 – 4 – 3 – 2 – 1 0000 0001 0011 1111 1110 1100 1011 1010 1000 0111 0110 0100 0010 0101 1001 1101 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 – 8 – 7 – 6 – 5 – 4 – 3 – 2 – 1 6 + 4 ⇒ –6 –7 – 3 ⇒ +6
  • 15. CSE370, Lecture 2 Gray and BCD codes Decimal Symbols 0 1 2 3 4 5 6 7 8 9 BCD Code 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 Decimal Symbols 0 1 2 3 4 5 6 7 8 9 Gray Code 0000 0001 0011 0010 0110 0111 0101 0100 1100 1101
  • 16. CSE370, Lecture 2 The physical world is analog  Digital systems need to  Measure analog quantities  Speech waveforms, etc  Control analog systems  Drive motors, etc  How do we connect the analog and digital domains?  Analog-to-digital converter (A/D)  Example: CD recording  Digital-to-analog converter (D/A)  Example: CD playback
  • 17. CSE370, Lecture 2 Sampling  Quantization  Conversion from analog to discrete values  Quantizing a signal  We sample it Datel Data Acquisition and Conversion Handbook
  • 18. CSE370, Lecture 2 Conversion  Encoding  Assigning a digital word to each discrete value  Encoding a quantized signal  Encode the samples  Typically Gray or binary codes Datel Data Acquisition and Conversion Handbook