Binary “There are 10 types of people in the world: Those who understand binary, and those who don't.”

Slides:



Advertisements
Similar presentations
©Brooks/Cole, 2003 Chapter 4 Operations on Bits. ©Brooks/Cole, 2003 Apply arithmetic operations on bits when the integer is represented in two’s complement.
Advertisements

James Tam Numerical Representations On The Computer: Negative And Rational Numbers How are negative and rational numbers represented on the computer? How.
Binary & Decimal numbers = 3* * *10 + 5*1 = 3* * * *10 0 Decimal system: Ten digits: 0,1,2,3,…,9 Example:
Assembly Language and Computer Architecture Using C++ and Java
Digital Circuit Why Digital Circuit? – Digital signals ( 0 and 1) are very easy to handle with electronic circuits only 2 states needed: Switch ON or OFF,
Signed Numbers Up till now we've been concentrating on unsigned numbers. In real life we have to represent signed numbers ( like: -12, -45, 78). The difference.
Signed Numbers.
Binary Arithmetic Math For Computers.
Binary Number Systems.
Binary Representation - Shortcuts n Negation x + x = 1111…1111 two = -1 (in 2’s complement) Therefore, -x = x + 1 n Sign Extension o Positive numbers :
The Binary Number System
Computer Organization & Programming Chapter2 Number Representation and Logic Operations.
Simple Data Type Representation and conversion of numbers
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.
Binary Real Numbers. Introduction Computers must be able to represent real numbers (numbers w/ fractions) Two different ways:  Fixed-point  Floating-point.
Conversion Between Lengths Positive number pack with leading zeros +18 = = Negative numbers pack with leading ones -18 =
Number Systems Part 2 Numerical Overflow Right and Left Shifts Storage Methods Subtraction Ranges.
Computer System & Binary Review. Memory Model What memory is supposed to look like.
1 COMS 161 Introduction to Computing Title: Numeric Processing Date: October 20, 2004 Lecture Number: 23.
CPS120: Introduction to Computer Science Computer Math: Converting to Decimal.
© 2010 Cisco Systems, Inc. All rights reserved. 1 Network Math.
©Brooks/Cole, 2003 Chapter 4 Operations on Bits. ©Brooks/Cole, 2003 Apply arithmetic operations on bits when the integer is represented in two’s complement.
Number Systems Revision of conversations What is a register Addition Complementation.
07/12/ Data Representation Two’s Complement & Binary Arithmetic.
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)
09/03/20161 Information Representation Two’s Complement & Binary Arithmetic.
Number Systems. Topics  The Decimal Number System  The Binary Number System  Converting from Binary to Decimal  Converting from Decimal to Binary.
Nguyen Le CS147.  2.4 Signed Integer Representation  – Signed Magnitude  – Complement Systems  – Unsigned Versus Signed Numbers.
{ Binary “There are 10 types of people in the world: Those who understand binary, and those who don't.”
Software Design and Development Storing Data Computing Science.
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.
973cs111_add_posneg.ppt Integers Whole numbers Do NOT contain decimal points (as in money) 43,689 is an integer 43, is NOT an integer (it is floating.
Floating Point Numbers
Nat 4/5 Computing Science Lesson 1: Binary
Cosc 2150: Computer Organization
Binary & Hex Review.
Binary & Decimal numbers
Design of Digital Circuits Reading: Binary Numbers
David Kauchak CS 52 – Spring 2017
Addition and Subtraction
Chapter 4 Operations on Bits.
Recap Add these numbers together in binary
1.11, 1.12, 1.13, 1.14, 1.18, 1.20, 1.23, 1.24, 1.25, 1.32, 1.33 ( 47 )8 = ( )2 ( 47 )16 = ( )2 ( 20 )10.
Numbers in a Computer Unsigned integers Signed magnitude
Boolean Algebra, Bitwise Operations
Data Representation Integers
Addition and Substraction
Binary Addition & Subtraction
The University of Adelaide, School of Computer Science
Topic 3: Data Signed Binary.
Teaching Computing to GCSE
Binary Math Basic operations.
Two’s Complement Shortcut
Binary Lesson 2 Bytes.
Binary Lesson 2 Bytes.
How are negative and rational numbers represented on the computer?
Chapter 3 DataStorage Foundations of Computer Science ã Cengage Learning.
Computer Organization
The basics of any electronic device means either electricity is flowing or it is not i.e. a switch is either on or off Computers are electronic devices.
Introduction to Programming Part 3
Task Planner for Column Addition Step What to do How it should look
Binary Numbers Material on Data Representation can be found in Chapter 2 of Computer Architecture (Nicholas Carter) CSIT 301 (Blum)
Binary & Hex Review.
Data Binary Arithmetic.
Chapter3 Fixed Point Representation
Task Planner for Column Addition Step What to do How it should look
Binary.
靜夜思 床前明月光, 疑是地上霜。 舉頭望明月, 低頭思故鄉。 ~ 李白 李商隱.
Theory: 2.6 – Data Representation
Two’s Complement & Binary Arithmetic
Presentation transcript:

Binary “There are 10 types of people in the world: Those who understand binary, and those who don't.”

What is Binary? Binary is the base-2 numeral system. We normally use the base-10 system. The only symbols in binary are “0” and “1”. “0” represents no electron flow, aka “OFF”. “1 “ represents electrons flowing, aka “ON”.

Bits and Bytes Each digit in a binary number is a bit. Eight bits make up one byte.

Base-10 versus Base-2 BASE 10 100 = 1 101 = 10 102 = 100 103 = 1000 Base-10 uses ten as the base of the exponent, while Base-2 uses a two for the base. BASE 10 100 = 1 101 = 10 102 = 100 103 = 1000 BASE 2 20 = 1 21 = 2 22 = 4 23 = 8

Converting Binary Values Add up all of the place values that hold a “1”. Place Values: 8’s, 4’s, 2’s, 1’s 0101 = 4 + 1 = 5 1110 = 8 + 4 + 2 = 14 0111 = 4 + 2 + 1 = 7

Adding Binary Numbers 0 1 0 1 . . . . . . 5 + 0 0 0 1 . . . . . . +1 0 + 1 = 1 1 + 0 = 1 1 + 1 = 10 . . . . . . carry the left “1” 1 + 1 + 1 = 11 . . . carry the left “1” 0 1 0 1 . . . . . . 5 + 0 0 0 1 . . . . . . +1 ================= 0 1 1 0 . . . . . . 6

What is an Overflow? 1 1 1 1 = 15 + 0 0 0 1 = + 1 ============ Overflow occurs when there is a carry into a column that doesn’t exist! 1 1 1 1 = 15 + 0 0 0 1 = + 1 ============ 0 0 0 0 = 0?

Unsigned versus Signed An unsigned binary number can only be positive and has all of it’s bits calculated into the size of the value. A signed binary number can be positive or negative. The left most bit determines the sign. “0” denotes positive, while “1” denotes negative. Unsigned 0 1 0 1 = 5 1 0 1 0 = 10 1 1 0 1 = 13 Sign&Mag 0 1 0 1 = 5 1 0 1 0 = -2 1 1 0 1 = -5

Problems with Sign&Mag There are two zeros: 0000 (+0) and 1000 (-0). It is possible to have a carry into the “sign bit” by accident, causing errors in math! 0 1 1 1 = 7 + 0 0 1 0 = 2 ============= 1 0 0 1 = -1? Should = 9

One’s Compliment 0 0 0 1 = 1 1 1 1 0 = -1 0 1 1 0 = 6 1 0 0 1 = -6 Flip all of the bits and call that negative! If you have a carry out from sign bit during addition, do an end-around carry! This still has two zeroes: 0000 and 1111. 0 0 0 1 = 1 (flip for negative) 1 1 1 0 = -1 0 1 1 0 = 6 (flip for negative) 1 0 0 1 = -6

Two’s Compliment 0 0 0 = 0 flip+1 maps to 0 0 0 Flip all of the bits, then add one, call it negative! Do not do an end-around-carry! 0 0 0 = 0 flip+1 maps to 0 0 0 0 0 1 = 1 flip+1 maps to 1 1 1 0 1 0 = 2 flip+1 maps to 1 1 0 0 1 1 = 3 flip+1 maps to 1 0 1 1 0 0 = -4 given to negative side 1 0 1 = -3 from mapped +3 1 1 0 = -2 from mapped +2 1 1 1 = -1 from mapped +1

Range of a Binary Number It depends on: Number of Bits System: Unsigned, Sign&Mag, One’s, Two’s 4-bit Unsigned can go from: 0 0 0 0 = “0” 1 1 1 1 = “15” 4-bit Signed in Two’s Compliment can go from: 1 0 0 0 = “-8” 0 1 1 1 = “7”