CS 1428. Binary Representation of Information Detecting Voltage Levels Why not 10 levels? Would be unreliable Not enough difference between states On/Off.

Slides:



Advertisements
Similar presentations
COE 202: Digital Logic Design Signed Numbers
Advertisements

James Tam Numerical Representations On The Computer: Negative And Rational Numbers How are negative and rational numbers represented on the computer? How.
James Tam Numerical Representations On The Computer: Negative And Rational Numbers How are negative and rational numbers represented on the computer? How.
James Tam Numerical Representations On The Computer: Negative And Rational Numbers How are negative and rational numbers represented on the computer?
1 CSE1301 Computer Programming Lecture 29: Number Representation (Part 1)
James Tam Numerical Representations On The Computer: Negative And Rational Numbers How are negative and rational numbers represented on the computer? How.
Arithmetic & Logic Unit Does the calculations Everything else in the computer is there to service this unit Handles integers May handle floating point.
James Tam Numerical Representations On The Computer: Negative And Rational Numbers How are negative and rational numbers represented on the computer? How.
CS 151 Digital Systems Design Lecture 3 More Number Systems.
Information Processing Session 5B Binary Arithmetic Slide
Computer ArchitectureFall 2008 © August 25, CS 447 – Computer Architecture Lecture 3 Computer Arithmetic (1)
1 CSE1301 Computer Programming Lecture 28 Number Representation (Integer)
Complements: different approaches for representing negative numbers
ENGIN112 L3: More Number Systems September 8, 2003 ENGIN 112 Intro to Electrical and Computer Engineering Lecture 3 More Number Systems.
Signed Numbers CS208. Signed Numbers Until now we've been concentrating on unsigned numbers. In real life we also need to be able represent signed numbers.
Computer ArchitectureFall 2007 © August 29, 2007 Karem Sakallah CS 447 – Computer Architecture.
NEGATIVE BINARY NUMBER – Digital Circuit 1 Choopan Rattanapoka.
1.6 Signed Binary Numbers.
Lecture 12: Computer Arithmetic Today’s topic –Numerical representations –Addition / Subtraction –Multiplication / Division 1.
Computer Organization & Programming Chapter2 Number Representation and Logic Operations.
Number Representations and Computer Arithmetic. CS 21a 9/23/02 Odds and Ends Slide 2 © Luis F. G. Sarmenta and John Paul Vergara, Ateneo de Manila University.
Lecture 5.
Number Systems Part 2 Numerical Overflow Right and Left Shifts Storage Methods Subtraction Ranges.
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,
ECEN2102 Digital Logic Design Lecture 1 Numbers Systems Abdullah Said Alkalbani University of Buraimi.
COMPSCI 210 Semester Tutorial 1
CPS120: Introduction to Computer Science Computer Math: Signed Numbers.
Calculating Two’s Complement. The two's complement of a binary number is defined as the value obtained by subtracting the number from a large power of.
46 Number Systems Problem: Implement simple pocket calculator Need: Display, adders & subtractors, inputs Display: Seven segment displays Inputs: Switches.
Representation of Data Ma King Man. Reference Text Book: Volume 2 Notes: Chapter 19.
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,
©Brooks/Cole, 2003 Chapter 3 Number Representation.
ECE 301 – Digital Electronics Unsigned and Signed Numbers, Binary Arithmetic of Signed Numbers, and Binary Codes (Lecture #2)
Cosc 2150: Computer Organization Chapter 2 Part 1 Integers addition and subtraction.
Positional Number Systems
Number Representation
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.
Number Systems and Logic Prepared by Dr P Marais (Modified by D Burford)
Data Representation in Computer Systems. 2 Signed Integer Representation The conversions we have so far presented have involved only positive numbers.
07/12/ Data Representation Two’s Complement & Binary Arithmetic.
1 2.1 Introduction A bit is the most basic unit of information in a computer. –It is a state of “on” or “off” in a digital circuit. –Sometimes these states.
Irvine, Kip R. Assembly Language for Intel-Based Computers 6/e, Signed Integers The highest bit indicates the sign. 1 = negative, 0 = positive.
CS1Q Computer Systems Lecture 2 Simon Gay. Lecture 2CS1Q Computer Systems - Simon Gay2 Binary Numbers We’ll look at some details of the representation.
69 Decimal (Base 10) Numbers n Positional system - each digit position has a value n 2534 = 2*1, * *10 + 4*1 n Alternate view: Digit position.
CS 1428 Foundations of Computer Science I. Two Main Components  Hardware  Physical media that uses electrical current to process instructions.  Software.
Bits, Data types, and Operations: Chapter 2 COMP 2610 Dr. James Money COMP
CPS3340 Computer Architecture Fall Semester, 2013
IT1004: Data Representation and Organization Negative number representation.
1 Digital Logic Design Lecture 2 More Number Systems/Complements.
James Tam Numerical Representations On The Computer: Negative And Rational Numbers How are negative and rational numbers represented on the computer? How.
ECE DIGITAL LOGIC LECTURE 3: DIGITAL COMPUTER AND NUMBER SYSTEMS Assistant Prof. Fareena Saqib Florida Institute of Technology Fall 2016, 01/19/2016.
Numerical formats What’s the main idea? Want to represent numbers (eg: 45, -12, ) using only bits. We’ve already seen (or you can read in the book)
ECEN 248: INTRODUCTION TO DIGITAL SYSTEMS DESIGN Lecture 8 Dr. Shi Dept. of Electrical and Computer Engineering.
Chapter 1 Representing Data in a Computer. 1.1 Binary and Hexadecimal Numbers.
09/03/20161 Information Representation Two’s Complement & Binary Arithmetic.
Computer Organization 1 Data Representation Negative Integers.
Nguyen Le CS147.  2.4 Signed Integer Representation  – Signed Magnitude  – Complement Systems  – Unsigned Versus Signed Numbers.
Number Systems Part 2. Counting in Binary DecimalBinary
Arithmetic Circuits I. 2 Iterative Combinational Circuits Like a hierachy, except functional blocks per bit.
Binary Addition The simplest arithmetic operation in binary is addition. Adding two single-digit binary numbers is relatively simple, using a form of carrying:
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.
Lecture 4: Digital Systems & Binary Numbers (4)
Cosc 2150: Computer Organization
David Kauchak CS 52 – Spring 2017
Computer Architecture & Operations I
University of Gujrat Department of Computer Science
Dr. Clincy Professor of CS
Dr. Clincy Professor of CS
How are negative and rational numbers represented on the computer?
Dr. Clincy Professor of CS
Presentation transcript:

CS 1428

Binary Representation of Information Detecting Voltage Levels Why not 10 levels? Would be unreliable Not enough difference between states On/Off Fully Charged - Fully Discharged Magnetized - Demagnetized 2

Bits, Bytes, and so on A bit is one 0 or 1 Short for “binary digit” A byte is a collection of 8 bits They named it “byte” instead of “bite” so you couldn’t easily mess up the spelling and confuse it with “bit”. 3

The Binary Numbering System A computer’s internal storage techniques are different from the way people represent information in daily lives We see and type numbers and letters. The computer sees ones and zeros for everything All information inside a digital computer is stored as a collection of binary data 4

Binary Representation of Numeric and Textual Information Binary numbering system Base-2 Built from ones and zeros Each position is a power of = 1 x x x x 2 0 Decimal numbering system Base-10 Each position is a power of = 3 x x x x

Binary Numbers Base 2 - digits 0 and 1 __________________

7

Calculating in binary First practice counting to in binary Practice adding: Try subtracting:

Representing Signed Numbers What about negative numbers? We can divide the bit patterns into two halves but we need to be careful What to do for zero? Need to consider binary arithmetic as well One approach is to use the sign and magnitude method Reserve 1 bit (usually the high-order bit) that represents the sign Rest of the bits make up the magnitude

Sign-and-Magnitude Easy to understand but not efficient Two representations for zero Lot of extra overhead to do binary arithmetic Recall the ALU from Lecture 1 ALU does binary arithmetic (mainly addition) We would need to redesign the ALU to do arithmetic with sign-and-magnitude representation What’s the alternative?

2’s complement The high-order bit represents the sign but the magnitude is computed differently Has a single representation for zero Has an extra negative number No extra overhead for binary arithmetic Almost all modern computers use this representation Example

Converting Decimal to 2’s Complement Get the binary representation for the absolute value of the number Flip all the bits Add 1 to the complement Example // 5-bit binary for absolute value of // all bits flipped // 1 added to the complement

Converting 2’s Complement to Decimal If the high-order bit is 0 then convert the number in the usual way Else Subtract 1 Flip all bits Convert to decimal Affix a minus sign

Converting 2’s Complement to Decimal Example // 2’s complement binary // 1 subtracted // bits flipped -6 // affixed the negative sign

2’s Complement Arithmetic Binary addition, discard the final carry Example Be careful of overflow For a 5 bit 2’s complement representation 16 is too large! -17 is too small!

More on 2s Complement arithmetic/twoscomplement.html arithmetic/twoscomplement.html

Summary Things you should be able to do Convert binary to decimal Convert decimal to binary Convert 2’s complement binary to decimal Convert decimal to 2’s complement binary Towards the end of the semester perhaps write a program that does this for you