CSC 110 – Intro to Computing Lecture 4: Arithmetic in other bases & Encoding Data.

Slides:



Advertisements
Similar presentations
Data Representation COE 202 Digital Logic Design Dr. Aiman El-Maleh
Advertisements

The Binary Numbering Systems
Binary Systems1 DIGITAL LOGIC DESIGN by Dr. Fenghui Yao Tennessee State University Department of Computer Science Nashville, TN.
CIS 020 Assembly Programming Chapter 02 - Numbering Systems & Data Representation © John Urrutia 2012, All Rights Reserved.5/27/20121.
CSC /703 CTI/DePaul1 CSC-255 Lecture 3 Text and Numerical Storage (Chapter 1 from Brookshear) Modified by Ufuk Verun from Jim Janossy © 2002, DePaul.
Connecting with Computer Science, 2e
Assembly Language and Computer Architecture Using C++ and Java
CSC 110 – Intro to Computing Lecture 14: Midterm Review.
CSC 110 – Intro to Computing Lecture 3: Converting between bases & Arithmetic in other bases.
Chapter Chapter Goals Know the different types of numbers Describe positional notation.
Professor Jennifer Rexford COS 217
Chapter 02 Binary Values and Number Systems Nell Dale & John Lewis.
John Owen, Rockport Fulton HS1 Computer Science LESSON 2 ON Number Bases.
The Binary Number System
IT-101 Section 001 Lecture #4 Introduction to Information Technology.
Chapter 1 The Big Picture. QUIZ 2 5 Explain the abstractions we normally apply when using the following systems: DVD player Registering for classes on.
2.1 2 Number Systems Foundations of Computer Science  Cengage Learning.
Binary Arithmetic Math For Computers.
Number Systems Lecture 02.
Connecting with Computer Science 2 Objectives Learn why numbering systems are important to understand Refresh your knowledge of powers of numbers Learn.
© Maths Support Service 2007 Binary and Hexadecimal Numbers Next Slide AE98FD AE98FD.
Chapter 16 Binary and Hexadecimal Numbers. §16.2 thru 16.3 – Addition and Subtraction of Binary Numbers Binary = Base 2 Addition and subtraction are similar.
Real Numbers and the Decimal Number System
(2.1) Fundamentals  Terms for magnitudes – logarithms and logarithmic graphs  Digital representations – Binary numbers – Text – Analog information 
Simple Data Type Representation and conversion of numbers
CS105 INTRODUCTION TO COMPUTER CONCEPTS BINARY VALUES & NUMBER SYSTEMS Instructor: Cuong (Charlie) Pham.
Numeration Systems Introduction to Binary, Octal, and Hexadecimal.
IT253: Computer Organization
Foundations of Computer Science Computing …it is all about Data Representation, Storage, Processing, and Communication of Data 10/4/20151CS 112 – Foundations.
Comp Sci 251 Intro 1 Computer organization and assembly language Wing Huen.
Compsci Today’s topics l Binary Numbers  Brookshear l Slides from Prof. Marti Hearst of UC Berkeley SIMS l Upcoming  Networks Interactive.
مدار منطقي مظفر بگ محمدي Course Structure & Grading Homework: 25% Midterm: 30% Final:50% There is 5% extra! ( =105!) Textbook:
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.
Number systems, Operations, and Codes
Positional Notation 642 in base 10 positional notation is:
Lecture 2 Binary Values and Number Systems. The number 943 is an example of a number written in positional notation. The relative positions of the digits.
CSC 110 – Intro to Computing Lecture 8: Computing Components.
CPIT 201 Introduction to Computing
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.
Announcement!!! First exam next Thursday (I’m trying to give you a first exam before the drop date) I’ll post a sample exam over the weekend and will try.
PHY 107 – Programming For Science. Positional Notation  Used in nearly all modern numerical systems  Right-to-left ordering of digits within larger.
Introduction To Number Systems Binary System M. AL-Towaileb1.
© 2010 Pearson Prentice Hall. All rights reserved. CHAPTER 4 Number Representation and Calculation.
Computer Science LESSON 2 ON Number Bases.
 2012 Pearson Education, Inc. Slide Chapter 4 NumerationSystems.
More Digital Representation Discrete information is represented in binary (PandA), and “continuous” information is made discrete.
CSC 110 – Intro to Computing Lecture 3: Converting between bases & Arithmetic in other bases.
CPIT 201 King AbdulAziz University Faculty of Computing & Information Technology Information Technology Department CH 2 Number Systems CPIT 201 Introduction.
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.
Binary & Hex Review.
Lecturer: Santokh Singh
Introduction To Number Systems
Chapter 02 Nell Dale & John Lewis.
Discrete Mathematics Numbering System.
Lecture 3: Binary values and number systems
Chapter R Prealgebra Review Decimal Notation.
Number Systems Lab session 1 Xuan Guo.
Number System conversions
University of Gujrat Department of Computer Science
EEL 3705 / 3705L Digital Logic Design
Information Representation
COMS 161 Introduction to Computing
Plan Attendance Files Posted on Campus Cruiser Homework Reminder
How Computers Store Data
COMS 161 Introduction to Computing
Binary & Hex Review.
Presentation transcript:

CSC 110 – Intro to Computing Lecture 4: Arithmetic in other bases & Encoding Data

Announcements Copies of the slides are available on Blackboard and the course web page before and after each class Your slips selecting your service learning site are due next Tuesday

Announcements Homework #1 will be handed out today (and is on the course web page). It is due in my box by Monday at 4PM Quiz #1 on numerical systems will be given next Thursday in class

Review of Important Bases Binary (base-2) uses 2 digits: 0 & 1 Octal (base-8) uses 8 digits: 0, 1, 2, 3, 4, 5, 6, 7 Decimal (base-10) uses 10 digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 Hexadecimal (base-16) uses 16 digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F

Converting To Decimal We use positional notation to convert a number d n...d 3 d 2 d 1 d 0 from base-b to decimal: d 0 * b 0 d 1 * b 1 d 2 * b 2 d 3 * b 3 … + d n * b n

Converting From Decimal Converting a number from decimal to base-b While the decimal number is not 0 Divide the decimal number by b Move remainder to left end of answer Replace decimal number with quotient

Converting Binary To Octal Starting at the right, split into groupings of 3 bits For each group (working from right to left) Convert group from binary to decimal Add decimal number to left-end of solution

Converting Octal To Binary For each digit (working from right to left) Convert the digit from decimal to binary Add 0s to left of the binary to fill 3 bits Add binary number to left-end of solution Finally, remove any 0s padding leftmost digit

Binary to powers-of-two bases Conversion similar to binary ↔ octal  Octal is base = 8 3 binary digits represent 1 octal digit  Hexadecimal is base = 16 4 binary digits represent 1 hexadecimal digit When converting to hexadecimal, remember to use A, B, C, D, E, F and not 10, 11, 12, 13, 14, 15 for digits

Decimal Addition How do we add:

Decimal Addition How do we add: ones ones 6 ones

Decimal Addition How do we add: ones ones 66 ones

Decimal Addition How do we add: tens tens 612 tens

Decimal Addition How do we add: tens tens 6 1 hundred 2 tens

Decimal Addition How do we add: tens tens 26 1 hundred 2 tens

Decimal Addition How do we add: hundred hundreds hundreds thousand 0 hundred

Decimal Addition How do we add: thousand thousand thousand thousand

Decimal Addition How do we add:

Oops… I forgot one detail I forgot this was supposed to be in octal

Adding in Octal I forgot this was supposed to be in octal ones +3 ones 6 ones

Adding in Octal I forgot this was supposed to be in octal ones +3 ones 6 ones Whew = 6 8

Adding in Octal 8 1 = = 8 * 8 = eights +6 eights 12 eights What do we do now?

Adding in Octal 8 1 = = 8 * 8 = eights +6 eights 12 eights 8 eights = 1 sixty-four

Adding in Octal 8 1 = = 8 * 8 = eights +6 eights 12 eights –or– 12-8 = 4 eights and 1 sixty-four

Adding in Octal 8 1 = = 8 * 8 = eights +6 eights 4 eights and 1 sixty-four

Adding in Octal 8 2 = sixty-four 7 sixty-four +2 sixty-four 10 sixty-fours

Adding in Octal 8 2 = = 64 * 8 = sixty-four 7 sixty-four +2 sixty-four 10-8 = 2 sixty-fours 1 two fifty-six

Adding in Octal Finally, something makes sense again two fifty-six 5 two fifty-six +1 two fifty-six 7 two fity-six Yes! 7 is an octal digit

Adding in Octal That’s all, folks!

Algorithm For each position from right to left

Addition Algorithm To add 2 numbers in base-b: For each position from right to left Compute sum of the digits If sum > b then Record sum - b at position Carry the 1 If sum < b Record sum at position

Algorithm For each position from right to left

Algorithm Compute sum of the digits6 + 2 =

Algorithm If sum > b thenIf 8 > 8 then

Algorithm Record sum - b for position8 – 8 =

Algorithm Carry the one

Algorithm For each position from right to left

Algorithm Compute sum of digits =

Algorithm If sum < b then 5 <

Algorithm Record sum for position

Algorithm For each position from right to left

Algorithm Compute sum of digits1 + 7 =

Algorithm If sum > b then8 >

Algorithm Record sum – b for position8 – 8 =

Algorithm Carry the one

Algorithm For each position from right to left

Algorithm Compute sum of digits1 =

Algorithm If sum < b then 1 <

Algorithm Record sum for position

Algorithm We’re Done!

Addition Algorithm To add numbers in base-b: For each position from right to left Compute sum of the digits If sum > b then Record sum - b at positionCarry the 1 If sum < b Record sum at position

Data Encoding In the real world, data (“information”) is analog  Falls along a infinite continuum Color changes when mixing paint Falling mercury levels as temperatures drop  Hard to capture numerically Is it o F or o F right now? Do you even care about this difference?

Data Encoding Normally, we work with discrete numbers  Round to nearest whole or rational number: 71 o F, 4.5 miles, 1 teaspoon  Limits the amount of space needed Imagine if the morning news had to put on screen: o F or state the time as: 8:45: Computers follow this pattern  It takes a lot of space to be precise!

Digitizing Data Computers work in binary (0-1)  Good news: we know how to convert any number into binary!  Suppose we have a CD containing pictures of my daughter, how do we turn the 0s and 1s on a CD into the colors that make up the cutest girl ever?

Color by Number Most pictures rely upon the RGB standard  First 8 bits (“byte”) specify amount of red used  Next byte specifies amount of green used  Last byte specifies amount of blue used  Mixing these numbers gives us many colors

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)

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 colors can 8 bits generate? How many different colors can n bits represent?

For Next Lecture Have Chapter 4 started Be ready to discuss:  Boolean logic  AND, OR, XOR, NOT, NAND, NOR gates