CSC 110 – Intro to Computing Lecture 3: Converting between bases & Arithmetic in other bases.

Slides:



Advertisements
Similar presentations
Representing Numbers: Integers
Advertisements

Connecting with Computer Science, 2e
Level ISA3: Information Representation
CSC 110 – Intro to Computing Lecture 14: Midterm Review.
CS 151 Digital Systems Design Lecture 2 Number Systems Prof. Ahmed Sameh Room 239A.
CSC 110 – Intro to Computing Lecture 4: Arithmetic in other bases & Encoding Data.
Chapter Chapter Goals Know the different types of numbers Describe positional notation.
Chapter 4.2 Binary numbers: Arithmetic
ENGIN112 L2: Number Systems September 5, 2003 ENGIN 112 Intro to Electrical and Computer Engineering Lecture 2 Number Systems Russell Tessier KEB 309 G.
Chapter 02 Binary Values and Number Systems Nell Dale & John Lewis.
The Binary Number System
Number Systems and Arithmetic
COMP201 Computer Systems Number Representation. Number Representation Introduction Number Systems Integer Representations Examples  Englander Chapter.
Lecture 2 Number Systems
Numbering Systems Decimal (Denary) base 10. Clumsy when dealing with computers. Other systems –Binary –Octal –Hexadecimal Convenient when dealing with.
Connecting with Computer Science 2 Objectives Learn why numbering systems are important to understand Refresh your knowledge of powers of numbers Learn.
Real Numbers and the Decimal Number System
(2.1) Fundamentals  Terms for magnitudes – logarithms and logarithmic graphs  Digital representations – Binary numbers – Text – Analog information 
Lecture for Week Spring.  Numbers can be represented in many ways. We are familiar with the decimal system since it is most widely used in everyday.
Numbering systems.
CS105 INTRODUCTION TO COMPUTER CONCEPTS BINARY VALUES & NUMBER SYSTEMS Instructor: Cuong (Charlie) Pham.
Numbering Systems CS208.
Chapter 11 Fluency with Information Technology 4 th edition by Lawrence Snyder (slides by Deborah Woodall : 1.
Chapter 3 Data Representation
Data Representation CS280 – 09/13/05. Binary (from a Hacker’s dictionary) A base-2 numbering system with only two digits, 0 and 1, which is perfectly.
ECEN2102 Digital Logic Design Lecture 1 Numbers Systems Abdullah Said Alkalbani University of Buraimi.
Chapter 2 Binary Values and Number Systems Chapter Goals Distinguish among categories of numbers Describe positional notation Convert numbers in.
CSC 110 – Intro to Computing Lecture 4: Arithmetic in other bases & Encoding Data.
Chapter 2 Binary Values and Number Systems. 2 2 Natural Numbers Zero and any number obtained by repeatedly adding one to it. Examples: 100, 0, 45645,
1 Week 2: Binary, Octal and Hexadecimal Numbers READING: Chapter 2.
Chapter 2 Binary Values and Number Systems Chapter Goals Distinguish among categories of numbers Describe positional notation Convert numbers in.
Binary Values and Number Systems Chapter Goals Distinguish among categories of numbers Describe positional notation Convert numbers in other bases.
Numbering System Base Conversion. Number systems Decimal – 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 Binary – 0, 1 Octal – 0, 1, 2, 3, 4, 5, 6, 7 Hexadecimal system.
Binary Values and Number Systems
Representing Information Digitally (Number systems) Nell Dale & John Lewis (adapted by Erin Chambers, Michael Goldwasser, Andrew Harrington)
Positional Notation 642 in base 10 positional notation is:
1 Data Representation Characters, Integers and Real Numbers Binary Number System Octal Number System Hexadecimal Number System Powered by DeSiaMore.
1 COMS 161 Introduction to Computing Title: The Digital Domain Date: September 6, 2004 Lecture Number: 6.
CSC 107 – Programming For Science. Positional Notation  Used in nearly all modern numerical systems  Right-to-left ordering of digits within larger.
Computer Math CPS120 Introduction to Computer Science Lecture 4.
PHY 107 – Programming For Science. Positional Notation  Used in nearly all modern numerical systems  Right-to-left ordering of digits within larger.
Chapter 1 Number Systems Digital Electronics. Topics discussed in last lecture Digital systems Advantages of using digital signals over analog. Disadvantages.
CPEN Digital Logic Design Binary Systems Spring 2004 C. Gerousis © Digital Design 3 rd Ed., Mano Prentice Hall.
1 Digital Logic Design Lecture 2 More Number Systems/Complements.
©2010 Cengage Learning SLIDES FOR CHAPTER 1 INTRODUCTION NUMBER SYSTEMS AND CONVERSION Click the mouse to move to the next page. Use the ESC key to exit.
Chapter 1 Representing Data in a Computer. 1.1 Binary and Hexadecimal Numbers.
CS151 Introduction to Digital Design Chapter 1: Digital Systems and Information Lecture 2 1Created by: Ms.Amany AlSaleh.
CSC 110 – Intro to Computing Lecture 3: Converting between bases & Arithmetic in other bases.
The Hexadecimal System is base 16. It is a shorthand method for representing the 8-bit bytes that are stored in the computer system. This system was chosen.
Number Systems and Binary Arithmetic Quantitative Analysis II Professor Bob Orr.
Digital logic COMP214  Lecture 2 Dr. Sarah M.Eljack Chapter 1 1.
Binary Values. Numbers Natural Numbers Zero and any number obtained by repeatedly adding one to it. Examples: 100, 0, 45645, 32 Negative Numbers.
Dr. ClincyLecture 2 Slide 1 CS Chapter 2 (1 of 5) Dr. Clincy Professor of CS Note: Do not study chapter 2’s appendix (the topics will be covered.
Prepared By: Norakmar Binti Mohd Nadzari CHAPTER 2 ARITHMETIC AND LOGIC UNIT.
Number Systems & Binary Arithmetic
Lecturer: Santokh Singh
Introduction To Number Systems
Digital Design Chapter One Digital Systems and Binary Numbers
Chapter 02 Nell Dale & John Lewis.
Number Systems and Binary Arithmetic
Logistics Always read the Calendar at
Convert Decimal to Binary
Number Systems Give qualifications of instructors:
Chapter 3 Data Representation
Number System conversions
Number Systems and Binary Arithmetic
EEL 3705 / 3705L Digital Logic Design
Digital Electronics and Microprocessors
Numeral systems (radix)
COMS 161 Introduction to Computing
Presentation transcript:

CSC 110 – Intro to Computing Lecture 3: Converting between bases & Arithmetic in other bases

Announcements Copies of the slides are available on Blackboard and the course web page before and after each class The end is near! All drop/add slips must be turned in by Sept. 7 th. I have a cool office. Please stop by and look (you could also me questions you have at the same time).

Converting binary to decimal Binary positional notation d n * 2 n-1 + d n-1 * 2 n-2 + … + d 2 * d 1 * 2 0 What is binary 1101 in decimal? d 4 = 1d 3 = 1d 2 = 0d 1 = = 1 * * * * 2 0 = = 13

Converting octal to decimal Octal positional notation d n * 8 n-1 + d n-1 * 8 n-2 + … + d 2 * d 1 * 8 0 What is octal 126 in decimal d 3 = 1d 2 = 2d 1 = = 1 * * * 8 0 = = 86

Self-Quiz What is the decimal number equal to:  Binary 1110?  Binary ?  Octal 31?  Octal 17?

Base 16 Also known as hexadecimal Uses 10 expected digits:  0, 1, 2, 3, 4, 5, 6, 7, 8, 9 Still needs 6 more; by convention we use:  A, B, C, D, E, F  A == “10”, B == “11”, C == “12”, …, F == “15”

Converting Hex to Decimal Equation converting base 16 to base 10: What is the decimal value of hex FACE?

Powers-of-Two Conversion Converting between binary and octal or hex is easy  Why? How many bits per octal digit? How many bits per nibble (hex digit)?

Converting Binary to Hex What is in hex? What is in hex?

Converting Hex to Binary What is 65D3 in binary? What is BEEF is binary?

Converting Octal and Binary What is octal 6743 in binary? What is binary in octal?

Converting from Base 10 Early programmers wrote programs entirely in binary  Decimal notation still rare today. Why?

Converting from Base 10 Conversion follows simple algorithm: Do Divide decimal number by new base Next left-most digit is remainder from division Replace decimal number with division quotient Repeat until decimal number is zero

Convert Decimal to Binary What is 10 (decimal) in binary?

Self-Test Convert into from decimal to binary:  14  63

Convert Decimal to Hex Convert from decimal to hex

Converting to/from decimal? Who is ready for this on midterm?  What questions do you have? If you are uncomfortable asking in class:  Ask anyway (others have same questions)!  Ask me in my office hours  Post anonymously on blackboard  Try exercises 28 – 34 in book (p )

Addition Refresher How do we add two numbers together?

Adding in other bases Rules are very synonmous  Carry the one when above value of base  For instance in base 2:  Or in base 8:

Adding binary numbers

Adding hexadecimal numbers FEED +FACE BEEF + EA7

Subtraction Refresher Subtraction is base 10:

Subtraction in other bases Rules are very synonmous  Borrow the value of base when necessary  For instance in base 2:  Or in base 8:

Subtracting octal numbers

Subtracting binary numbers

Data Encoding Data (“information”) is traditionally encoded in analog formats  Falls along a continuum with lots of minimal changes Color changes when mixing paint Rising mercury levels when temperature increases  Easy for nature, but hard to capture numerically How to capture precision: Is it o F or o F?

Encoding Data Easier to encode discrete data  E.g., Using integer or rational numbers 71 o F or 4.5 miles.  Also bounds space needed to record data For this reason, computers only use discrete data

Digitizing Data Computers work in binary (0-1)  Makes computing cheaper and simpler  Limited loss of precision: Can convert all integers into binary How does this work?

Digitizing Data Figure 3.3 Signals in this region considered 0 Signals in this region considered 1 How digital data is captured and processed

Binary Representation 1 bit captures 2 states: 0 or 1 2 bits captures 4 states: 00, 01, 10, 11 3 bits capture 8 states: 000, 001, 010, 011, 100, 101, 110, 111

Binary Representation How many states can 4 bits capture? How many different states can n bits represent?

Data Storage Storing data can require lots of space  Each pixel (dot) in a color photo takes 4 bytes  5 megapixel (~million pixel) camera: 20MB per picture  32 pictures: 640MB (a CD holds 650MB)

Compression Much of this data is repetitive or unneeded  Areas in pictures contain similar data Pixels of clothing, leaves, or the sky will be similar  Music contains lots of sounds we cannot hear Compression limits the space data uses

2 types of compression Lossless compression  Lmt spce tkn w/o losing data  Important when all data is important E.g., bank records, grade reports, census data Lossy compression  No(table) because data is lost in compression  Useful when not all data is important E.g. mp3 files remove sounds people cannot hear

Compression Ratios Another way to compare algorithms is their compression rate  Measures how well data are compressed  Expressed as a value between 0% and 100% 0%  perfect compression 100%  no compression Most algorithms lie somewhere in between

For Next Lecture Have Chapter 3 finished Be ready to discuss:  Hexadecimal numbers  Converting from decimal to other bases  Arithmetic in bases other than 10