Foundations of Computer Science Computing …it is all about Data Representation, Storage, Processing, and Communication of Data 10/4/20151CS 112 – Foundations.

Slides:



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

The Binary Numbering Systems
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.
CSCE 211: Digital Logic Design Chin-Tser Huang University of South Carolina.
Chapter Chapter Goals Know the different types of numbers Describe positional notation.
Chapter 02 Binary Values and Number Systems Nell Dale & John Lewis.
CISC1400: Binary Numbers & Computer Fall 2011, Dr. Zhang 1.
Connecting with Computer Science 2 Objectives Learn why numbering systems are important to understand Refresh your knowledge of powers of numbers Learn.
Data Representation in Computers
Chapter 5 Data representation.
(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
ES 244: Digital Logic Design Chapter 1 Chapter 1: Introduction Uchechukwu Ofoegbu Temple University.
CS105 INTRODUCTION TO COMPUTER CONCEPTS BINARY VALUES & NUMBER SYSTEMS Instructor: Cuong (Charlie) Pham.
MATH 224 – Discrete Mathematics
Numeral Systems Subjects: Numeral System Positional systems Decimal
Computers Organization & Assembly Language
CSCI-365 Computer Organization Lecture Note: Some slides and/or pictures in the following are adapted from: Computer Organization and Design, Patterson.
Numbering Systems CS208.
Computer Arithmetic Nizamettin AYDIN
How Computers Work Dr. John P. Abraham Professor UTPA.
Click to edit Master title style Click to edit Master text styles –Second level Third level –Fourth level »Fifth level 1 Today’s Topics How information.
Computer Science 111 Fundamentals of Programming I Number Systems.
IT253: Computer Organization
Lec 3: Data Representation Computer Organization & Assembly Language Programming.
ECEN2102 Digital Logic Design Lecture 1 Numbers Systems Abdullah Said Alkalbani University of Buraimi.
1 Problem Solving using computers Data.. Representation & storage Representation of Numeric data The Binary System.
Information Representation. Digital Hardware Systems Digital Systems Digital vs. Analog Waveforms Analog: values vary over a broad range continuously.
Compsci Today’s topics l Binary Numbers  Brookshear l Slides from Prof. Marti Hearst of UC Berkeley SIMS l Upcoming  Networks Interactive.
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,
Cosc 2150: Computer Organization Chapter 2 Part 1 Integers addition and subtraction.
Binary Values and Number Systems Chapter Goals Distinguish among categories of numbers Describe positional notation Convert numbers in other bases.
Binary Values and Number Systems
Positional Notation 642 in base 10 positional notation is:
Compsci Today’s topics l Binary Numbers  Brookshear l Slides from Prof. Marti Hearst of UC Berkeley SIMS l Upcoming  Networks Interactive.
CISC1100: Binary Numbers Fall 2014, Dr. Zhang 1. Numeral System 2  A way for expressing numbers, using symbols in a consistent manner.  " 11 " can be.
THE BINARY SYSTEM.
Data Representation, Number Systems and Base Conversions
Data Representation.
1 Problem Solving using Computers “Data....Representation, and Storage.
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,
What is Binary Code? Computers use a special code of their own to express the digital information they process. It's called the binary code because it.
Lecture 2: 8/29/2002CS149D Fall CS149D Elements of Computer Science Ayman Abdel-Hamid Department of Computer Science Old Dominion University Lecture.
Information in Computers. Remember Computers Execute algorithms Need to be told what to do And to whom to do it.
Number Systems. ASCII – American Standard Code for Information Interchange – Standard encoding scheme used to represent characters in binary format on.
Number Systems. The position of each digit in a weighted number system is assigned a weight based on the base or radix of the system. The radix of decimal.
Binary Values. Numbers Natural Numbers Zero and any number obtained by repeatedly adding one to it. Examples: 100, 0, 45645, 32 Negative Numbers.
Unit 1 Introduction Number Systems and Conversion.
Cosc 2150: Computer Organization
Invitation to Computer Science, C++ Version, Fourth Edition
NUMBER SYSTEMS.
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.
Digital Logic and Computer Organization
3.1 Denary, Binary and Hexadecimal Number Systems
Fundamentals & Ethics of Information Systems IS 201
University of Gujrat Department of Computer Science
Invitation to Computer Science, Java Version, Third Edition
The Building Blocks: Binary Numbers, Boolean Logic, and Gates
How Computers Store Data
Chapter Four Data Representation in Computers By Bezawit E.
COMS 161 Introduction to Computing
Networks & I/O Devices.
Presentation transcript:

Foundations of Computer Science Computing …it is all about Data Representation, Storage, Processing, and Communication of Data 10/4/20151CS 112 – Foundations of Computer Science

A Computational Machine  What capabilities should a computing machine have ?  Well..any computational problem involves two primary elements: Data (numbers, text strings, or images,...) used for input, manipulation and output Instructions (that describes the operations (e.g. arithmetic or comparison) that must be performed on data pertinent to the problem being solved Von Neumann – provided the insight that both data and instructions could be stored together in the computer 10/4/20152CS 112 – Foundations of Computer Science

A Computational Machine  Thus, the machine must have the following capabilities: Representation & Storage (of both Data, and the Instructions that defines operations on data, why?) Data Processing (interpret Instructions and carry out operations defined by these instructions on Data) Data input and Data output (I/O) (why?) Data Communication (optional, if the machine is connected to other similar machines – via a network) 10/4/20153CS 112 – Foundations of Computer Science

Computer Capabilities  A transistor can be set to either on (1) or off (0) by controlling the direction of the electric current passing through it  Hundreds of Millions of transistors can be packed into a small ‘compact’ unit called the integrated circuit (IC) (a.k.a chips) Transistor is said to be storing a 1 here 5 Volts = 1 is stored Power source resistance Electric current transistor Transistor is said to be storing a 0 here 0 Volts = 0 is stored Power source No resistance Electric current transistor 10/4/20154CS 112 – Foundations of Computer Science

Computer Capabilities “Information in the Computer is bits + context”  Both data and instructions are encoded in the computer using Bits (Binary digits)  Think of a Bit as a code that can be either equal to 0 or 1  Encoding means that for each data value or algorithm instruction you use a code consisting of one or more bits to represent it.  For example, Street Traffic lights is a form of encoding for instructions to motorists (red = ‘stop’, yellow = ‘slow down’, green = ‘go’)  In computers bits are grouped together in 8-bit chunks called Bytes (e.g , , and ) 10/4/20155CS 112 – Foundations of Computer Science

Computer Capabilities Representation the encoding data using bits, and the encoding instructions using bits Storage storing bits used to encode data and instructions Data Processing for each instruction: 1) Interpreting the bits of the instruction, and 2) doing the operation specified in the instruction on the bits of the data specified in the instruction 10/4/20156CS 112 – Foundations of Computer Science

Computer Capabilities Data Input converting data transferred into the machine (say through a keyboard or mouse) into bits (and storing these bits) Data Output converting bits of data into appropriate format for transfer outside the machine (e.g. to the screen) Data Communication Transfer bits of data from one computer to another 10/4/20157CS 112 – Foundations of Computer Science

Computer Capabilities  What are some of the different types of data that may be encountered? Text (sequences of characters used to represent names, descriptions, etc.) Numeric (to represent different quantities, e.g. age, length, height, amount of money, growth rates) Image (to represent photographic or synthesized pictures) Audio (to represent audio signals of humans and otherwise) Video (to represent video signals) 10/4/20158CS 112 – Foundations of Computer Science

Computer Capabilities  What are some of the different types of instructions that may be used on this data? Text (extracting characters, Concatenating characters together, comparing characters) Numeric (arithmetic +, -, *, , comparison among other operations) Audio (manipulate pitch, volume, high or low frequencies in an audio signal) Image (manipulate pixels properties, e.g. color) 10/4/20159CS 112 – Foundations of Computer Science

Data Representation & Storage Representation by encoding works as follows:  First you have a value set; a fixed set of values you want to encode (data values likes numbers, characters, instructions to motorists,etc.).  You have a symbol set; a fixed set of symbols to use in constructing codes for these values (for computers this is generally the symbols {0,1}).  Using combinations of the symbols found in the symbol set you construct a unique code corresponding to each value in the value set. 10/4/201510CS 112 – Foundations of Computer Science

Data Representation & Storage Exercise I To save Money a new traffic light device will be deployed where only two colors are available red & green; propose an encoding scheme that allows the stop, slow down, and go instructions to be given to motorists using this new traffic light device Answer  What’s the value set ?  What’s the symbol set?  What’s the encoding scheme? 10/4/201511CS 112 – Foundations of Computer Science

Data Representation & Storage Exercise I To save Money a new traffic light device will be deployed where only two colors are available red & green; propose an encoding scheme that allows the stop, slow down, and go instructions to be given to motorists using this new traffic light device Answer  What’s the value set ? stop, slow down & go  What’s the symbol set? red & green  What’s the encoding scheme? stop = red, go = green & slow down = red & green 10/4/201512CS 112 – Foundations of Computer Science

Numeric Representation  What does 943 mean?  As a decimal number 10/4/201513CS 112 – Foundations of Computer Science

Numeric Representation  What does 943 mean?  As a decimal number 9 * 10 2 = 9 * 100= * 10 1 = 4 * 10= * 10 0 = 3 * 1= called positional notation here represented in base 10 10/4/201514CS 112 – Foundations of Computer Science

Binary Representation  Generally speaking binary representation (base 2) of integers will use the symbols 0 & 1 in a positional representation where positions represent powers of or thus = = 25 10/4/201515CS 112 – Foundations of Computer Science

Binary Representation  Represent the decimal number 125 in binary  The standard algorithm (1) Start with your number, here 125, in base 10 (2) Divide the number (125) by 2 and record the remainder 125 / 2 has a quotient of 62 and a remainder of 1 (3) If the quotient = 0 stop, else Go to step 2 and repeat using the quotient as the number (4) Record the remainders recorded from right to left 10/4/201516CS 112 – Foundations of Computer Science

Binary Representation QR 125 / / / / / / / = /4/201517CS 112 – Foundations of Computer Science

Binary Addition How did we learn to add? ?? Do you remember the tables ?? = = = = 10 carry (hmmm… why didn’t they give us this in grade school?) 10/4/201518CS 112 – Foundations of Computer Science

Binary Addition  Example carry /4/201519CS 112 – Foundations of Computer Science

Negative Numbers Sign and Magnitude It's what we're used to: Fortunately there are only two choices for the sign: + and - So why no add a bit, and then use 0 for + and 1 for - Thus > - 38 sign bit 10/4/201520CS 112 – Foundations of Computer Science magnitude

Negative Numbers Among other things this leads to two zeros = +0 and = -0 that aren't really different numbers. Try instead something called 2’s complement 10/4/201521CS 112 – Foundations of Computer Science

Negative Numbers Might think of as clock arithmetic /4/201522CS 112 – Foundations of Computer Science

Addition and Subtraction = 5 or = /4/201523CS 112 – Foundations of Computer Science

Addition and Subtraction = 3 or = /4/201524CS 112 – Foundations of Computer Science

Addition and Subtraction = -3 or = /4/201525CS 112 – Foundations of Computer Science

Negative Numbers 2’s Complement Take the 1’s complement and add 1 5 -> 01011’s comp -> 1010 add > -5 Now go the other way -5 -> 10111’s comp -> 0100 add > 5 Thus the 2’s complement of a 2’s complement is the original number (same is true for the negative) 10/4/201526CS 112 – Foundations of Computer Science

Negative Numbers Find -56 using an eight bit representation 56 -> 's comp add > -56 What does represent? 2's complement it > 71 so the original number must have been /4/201527CS 112 – Foundations of Computer Science

Negative Numbers Find -83 using an eight bit representation What does represent? What does represent? 10/4/201528CS 112 – Foundations of Computer Science

Need More Bits Positive Numbers – Fill new positions to the left with 0 7 in four bits= in eight bits= in sixteen bits= Negative Numbers – Fill new positions to the left with 1 -7 in four bits= in eight bits= in sixteen bits= /4/201529CS 112 – Foundations of Computer Science

Addition and Subtraction Addition – follow the usual rules = = carry out – ignored, it means you passed /4/201530CS 112 – Foundations of Computer Science

Addition and Subtraction Subtraction can be represented as the addition of the negative > 7 + (-5) >-4 + (-3) /4/201531CS 112 – Foundations of Computer Science

Addition and Subtraction So is there any concern? Yes – no matter how many bits you use there is some maximum and some minimum number that can be represented. For four bits those are +7 and -8 respectively = 11 and -6 + (-4) = -10 are beyond a 4-bit rep /4/201532CS 112 – Foundations of Computer Science

Addition and Subtraction So is there any concern? Yes – no matter how many bits you use there is some maximum and some minimum number that can be represented. For four bits those are +7 and -8 respectively = 11 and -6 + (-4) = -10 are beyond a 4-bit rep two positives added to a negative 10/4/201533CS 112 – Foundations of Computer Science

Addition and Subtraction So is there any concern? Yes – no matter how many bits you use there is some maximum and some minimum number that can be represented. For four bits those are +7 and -8 respectively = 11 and -6 + (-4) = -10 are beyond a 4-bit rep two negatives added to a positive 10/4/201534CS 112 – Foundations of Computer Science

Addition and Subtraction So is there any concern? Yes – no matter how many bits you use there is some maximum and some minimum number that can be represented. For four bits those are +7 and -8 respectively = 11 and -6 + (-4) = -10 are beyond a 4-bit rep Both cases are called overflow. 10/4/201535CS 112 – Foundations of Computer Science

Addition and Subtraction Carry out the following – if there is overflow indicate that – if there is no overflow interpret your answer in decimal form. Numbers are listed in 2's complement /4/201536CS 112 – Foundations of Computer Science

Addition and Subtraction Carry out the following – if there is overflow indicate that – if there is no overflow interpret your answer in decimal form. Numbers are listed in 2's complement. 1001(-7) (5) (-2) /4/201537CS 112 – Foundations of Computer Science

Addition and Subtraction Carry out the following – if there is overflow indicate that – if there is no overflow interpret your answer in decimal form. Numbers are listed in 2's complement. 1001(-7) 0011(3) (5) 0110(6) (-2) 1001(X) /4/201538CS 112 – Foundations of Computer Science

Addition and Subtraction Carry out the following – if there is overflow indicate that – if there is no overflow interpret your answer in decimal form. Numbers are listed in 2's complement. 1001(-7) 0011(3) 0111(7) (5) 0110(6) 0011(3) (-2) 1001(X) 1010(X) /4/201539CS 112 – Foundations of Computer Science

Addition and Subtraction Carry out the following – if there is overflow indicate that – if there is no overflow interpret your answer in decimal form. Numbers are listed in 2's complement. 1001(-7) 0011(3) 0111(7) 1111(-1) (5) 0110(6) 0011(3) 1000(-8) (-2) 1001(X) 1010(X)10111(X) /4/201540CS 112 – Foundations of Computer Science

Addition and Subtraction Carry out the following – if there is overflow indicate that – if there is no overflow interpret your answer in decimal form. Numbers are listed in 2's complement. 1001(-7) 0011(3) 0111(7) 1111(-1) 1010(-6) 0101(5) 0110(6) 0011(3) 1000(-8) 0011(3) 1110(-2) 1001(X) 1010(X)10111(X) 1101(-3) /4/201541CS 112 – Foundations of Computer Science

Addition and Subtraction Carry out the following – if there is overflow indicate that – if there is no overflow interpret your answer in decimal form. Numbers are listed in 2's complement. 1001(-7) 0011(3) 0111(7) 1111(-1) 1010(-6) 0101(5) 0110(6) 0011(3) 1000(-8) 0011(3) 1110(-2) 1001(X) 1010(X)10111(X) 1101(-3) 1001(-7) (-5) (X) 10/4/201542CS 112 – Foundations of Computer Science

Addition and Subtraction Carry out the following – if there is overflow indicate that – if there is no overflow interpret your answer in decimal form. Numbers are listed in 2's complement. 1001(-7) 0011(3) 0111(7) 1111(-1) 1010(-6) 0101(5) 0110(6) 0011(3) 1000(-8) 0011(3) 1110(-2) 1001(X) 1010(X)10111(X) 1101(-3) 1001(-7) 0011(3) (-5) 1010(-6) (X) 1101(-3) 10/4/201543CS 112 – Foundations of Computer Science

Addition and Subtraction Carry out the following – if there is overflow indicate that – if there is no overflow interpret your answer in decimal form. Numbers are listed in 2's complement. 1001(-7) 0011(3) 0111(7) 1111(-1) 1010(-6) 0101(5) 0110(6) 0011(3) 1000(-8) 0011(3) 1110(-2) 1001(X) 1010(X)10111(X) 1101(-3) 1001(-7) 0011(3) 0111(7) (-5) 1010(-6) 1101(-3) (X) 1101(-3)10100(4) 10/4/201544CS 112 – Foundations of Computer Science

Addition and Subtraction Carry out the following – if there is overflow indicate that – if there is no overflow interpret your answer in decimal form. Numbers are listed in 2's complement. 1001(-7) 0011(3) 0111(7) 1111(-1) 1010(-6) 0101(5) 0110(6) 0011(3) 1000(-8) 0011(3) 1110(-2) 1001(X) 1010(X)10111(X) 1101(-3) 1001(-7) 0011(3) 0111(7) 1111(-1) (-5) 1010(-6) 1101(-3) 0111(7) (X) 1101(-3)10100(4)10110(6) 10/4/201545CS 112 – Foundations of Computer Science

Addition and Subtraction Carry out the following – if there is overflow indicate that – if there is no overflow interpret your answer in decimal form. Numbers are listed in 2's complement. 1001(-7) 0011(3) 0111(7) 1111(-1) 1010(-6) 0101(5) 0110(6) 0011(3) 1000(-8) 0011(3) 1110(-2) 1001(X) 1010(X)10111(X) 1101(-3) 1001(-7) 0011(3) 0111(7) 1111(-1) 1010(-6) 1011(-5) 1010(-6) 1101(-3) 0111(7) 1101(-3) 10011(X) 1101(-3)10100(4)10110(6)10111(X) 10/4/201546CS 112 – Foundations of Computer Science