CPSC 171 Introduction to Computer Science Binary.

Slides:



Advertisements
Similar presentations
The Binary Numbering Systems
Advertisements

Computer Science 101 Binary Systems. Humans Decimal Numbers (base 10) Decimal Numbers (base 10) Sign-Magnitude (-324) Sign-Magnitude (-324) Decimal Fractions.
Chapter 4: The Building Blocks: Binary Numbers, Boolean Logic, and Gates Invitation to Computer Science, Java Version, Third Edition.
Chapter 4: The Building Blocks: Binary Numbers, Boolean Logic, and Gates Invitation to Computer Science, C++ Version, Third Edition.
Data Representation Computer Organization &
Chapter 4: The Building Blocks: Binary Numbers, Boolean Logic, and Gates Invitation to Computer Science, C++ Version, Third & Fourth Edition Spring 2008:
Data Representation COE 205
Connecting with Computer Science, 2e
Introduction to Programming with Java, for Beginners
Chapter 4: The Building Blocks: Binary Numbers, Boolean Logic, and Gates Invitation to Computer Science, C++ Version, Third Edition.
Chapter 4: The Building Blocks: Binary Numbers, Boolean Logic, and Gates Invitation to Computer Science, C++ Version, Fourth Edition.
1 A Balanced Introduction to Computer Science, 2/E David Reed, Creighton University ©2008 Pearson Prentice Hall ISBN Chapter 12 Data.
Number Systems Computer Science 210 Computer Organization.
Connecting with Computer Science 2 Objectives Learn why numbering systems are important to understand Refresh your knowledge of powers of numbers Learn.
Chapter 5 Data representation.
1 Week 3: Data Representation: Negative Numbers READING: Chapter 3.
Simple Data Type Representation and conversion of numbers
Binary System and Logical Gates
Lecture 5.
Binary Representation. Binary Representation for Numbers Assume 4-bit numbers 5 as an integer  as an integer  How? 5.0 as a real number  How?
Introduction to Number Representation F451 Year 10 Computing Binary Numbers Binary Numbers Sign/Magnitude Sign/Magnitude 2s Complement 2s Complement Binary.
Computers Organization & Assembly Language
Binary Real Numbers. Introduction Computers must be able to represent real numbers (numbers w/ fractions) Two different ways:  Fixed-point  Floating-point.
2-1 Chapter 2 - Data Representation Principles of Computer Architecture by M. Murdocca and V. Heuring © 1999 M. Murdocca and V. Heuring Chapter Contents.
Invitation to Computer Science 5th Edition
Shawlands Academy Higher Computing Data Representation.
Foundations of Computer Science Computing …it is all about Data Representation, Storage, Processing, and Communication of Data 10/4/20151CS 112 – Foundations.
Dale & Lewis Chapter 3 Data Representation. Data and computers Everything inside a computer is stored as patterns of 0s and 1s Numbers, text, audio, video,
Data Representation and Computer Arithmetic
Lec 3: Data Representation Computer Organization & Assembly Language Programming.
CHAPTER 1 INTRODUCTION NUMBER SYSTEMS AND CONVERSION.
CH09 Computer Arithmetic  CPU combines of ALU and Control Unit, this chapter discusses ALU The Arithmetic and Logic Unit (ALU) Number Systems Integer.
Chapter 03 Data Representation. 2 Chapter Goals Distinguish between analog and digital information Explain data compression and calculate compression.
1 COMS 161 Introduction to Computing Title: Numeric Processing Date: October 20, 2004 Lecture Number: 23.
Compsci Today’s topics l Binary Numbers  Brookshear l Slides from Prof. Marti Hearst of UC Berkeley SIMS l Upcoming  Networks Interactive.
CHAPTER 1 INTRODUCTION NUMBER SYSTEMS AND CONVERSION
Lecture 5. Topics Sec 1.4 Representing Information as Bit Patterns Representing Text Representing Text Representing Numeric Values Representing Numeric.
©Brooks/Cole, 2003 Chapter 3 Number Representation.
Invitation to Computer Science 6th Edition Chapter 4 The Building Blocks: Binary Numbers, Boolean Logic, and Gates.
The Teacher CP4 Binary and all that… CP4 Revision.
Chapter 1 Data Storage © 2007 Pearson Addison-Wesley. All rights reserved.
Data Representation, Number Systems and Base Conversions
Chapter 4: The Building Blocks: Binary Numbers, Boolean Logic, and Gates Invitation to Computer Science,
Data Representation. How is data stored on a computer? Registers, main memory, etc. consists of grids of transistors Transistors are in one of two states,
AP LITERATURE AND COMPOSITION “IT’S A ‘TO BE OR NOT TO BE’ THURSDAY!” January 12, 2012 – Mr. Houghteling.
Lecture 2: 8/29/2002CS149D Fall CS149D Elements of Computer Science Ayman Abdel-Hamid Department of Computer Science Old Dominion University Lecture.
Bits, Data types, and Operations: Chapter 2 COMP 2610 Dr. James Money COMP
Software Design and Development Storing Data Computing Science.
Nat 4/5 Computing Science Lesson 1: Binary
Fundamentals of Computer Science
Computer Science: An Overview Eleventh Edition
Invitation to Computer Science, C++ Version, Fourth Edition
Lec 3: Data Representation
Everything is a number Everything in a computer memory and on storages is a number. Number  Number Characters  Number by ASCII code Sounds  Number.
CHAPTER 1 INTRODUCTION NUMBER SYSTEMS AND CONVERSION
Invitation to Computer Science, Java Version, Third Edition
Invitation to Computer Science, C++ Version, Third Edition
The Building Blocks: Binary Numbers, Boolean Logic, and Gates
Invitation to Computer Science 6th Edition
How Computers Store Data
COMS 161 Introduction to Computing
Presentation transcript:

CPSC 171 Introduction to Computer Science Binary

Announcements Read Chapter 4 Lab 4 & 5 due tomorrow at beginning of Lab Homework 3 due this Friday at beginning of Lecture EXAM Friday October 2 nd in class

Example Representation Real World To be, or not to be: that is the question: Whether 'tis nobler in the mind to suffer The slings and arrows of outrageous fortune, Or to take arms against a sea of troubles, And by opposing end them? To die: to sleep; No more; and by a sleep to say we end The heart-ache and the thousand natural shocks That flesh is heir to, 'tis a consummation Devoutly to be wish'd. -- William Shakespeare - (from Hamlet Act 3, Scene 1) Computer World …

Internal and External Representation of Data Real World Integers: 34 Signed Integers: -156 Decimal Numbers: Text: Hello Music: Hey Jude Pictures: Computer World Zeros and Ones:

Integer Representation We use a base 10 number system (Decimal) 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 2,359 tens hundreds thousands ones Computers use a base 2 number system (Binary) 0,

Conversion from Binary to Decimal 1x2 5 +1x2 4 +0x2 3 +1x2 2 +0x2 1 +1x2 0 =53 You Try it: What are the following binary numbers in decimal?

Conversion from Decimal to Binary Perform repeated divisions by 2 Keep track of the remainders 19 / 2quotient = 9remainder = 1 9 / 2quotient = 4remainder = 1 4 / 2quotient = 2remainder = 0 2 / 2quotient = 1remainder = 0 1 / 2quotient = 0remainder = 1 Stop when the quotient is 0 Decimal number 19 in binary is You Try it Convert the following decimal numbers to binary

Addition on Binary = = = = 10 (carry the 1)

Fixed Sizes for Numbers On computers a fixed number of digits are typically used to store a number (8, 16, 32, or 64 bits are common) The decimal number 3 in binary is 11, but using a fixed size of 8 bits it would be represented as Try adding the binary numbers using a fixed size of 8 bits:

Internal and External Representation of Data Real World Integers: 34 Signed Integers: -156 Decimal Numbers: Text: Hello Music: Hey Jude Pictures: √

Signed Integers -134 Sign/Magnitude Notation magnitude Sign 0 = positive 1 = negative Not frequently used on computers 2 numbers for zero Not easy to add/subtract

Signed Integers -134 Two’s Complement Notation (for fixed size window 16) 1. Calculate the magnitude in binary Flip the bits Add one You Try it

Internal and External Representation of Data Real World Integers: 34 Signed Integers: -156 Decimal Numbers: Text: Hello Music: Hey Jude Pictures: √ √

Decimal Numbers 5.75 Write the 5 in binary and the 0.75 in binary 5 – – 0.11 Normalize the number, keeping track of Mantissa and Exponent: ±MxB ±E M – Mantissa B – Base (we use base 2) E – Exponent Used fixed size window (16 bits) First bit is sign Next 9 bits are Mantissa Next bit is sign Last 5 bits are Exponent You Try It:

Text Fixed Size Window represents a character ASCII (8 bits)pg 141 in text Unicode (16 bits)represents 65,636 characters

Binary Representation of Sound and Images Multimedia data is sampled to store a digital form with or without detectable differences Representing sound data Sound data must be digitized for storage in a computer Digitizing means periodic sampling of amplitude values

Binary Representation of Sound and Images (continued) From samples, original sound can be approximated To improve the approximation  Sample more frequently  Use more bits for each sample value

Figure 4.5 Digitization of an Analog Signal (a) Sampling the Original Signal (b) Recreating the Signal from the Sampled Values

Representing image data Images are sampled by reading color and intensity values at even intervals across the image Each sampled point is a pixel Image quality depends on number of bits at each pixel Binary Representation of Sound and Images (continued)

Pictures For each pixel keep track of: RGB values (8-bit)

Why Binary Representation Electronic devices are most reliable in a bistable environment Bistable environment Distinguishing only two electronic states  Current flowing or not  Direction of flow Computers are bistable: binary representations

Magnetic core Historic device for computer memory Tiny magnetized rings; flow of current sets the direction of magnetic field Binary values 0 and 1 are represented using the direction of the magnetic field Binary Storage Devices

Figure 4.9 Using Magnetic Cores to Represent Binary Values

Transistors Solid-state switches; either permit or block current flow A control input causes state change Constructed from semiconductors Binary Storage Devices (continued)

Figure 4.11 Simplified Model of a Transistor