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 :

Slides:



Advertisements
Similar presentations
Representing Numbers: Integers
Advertisements

HEXADECIMAL NUMBERS Code
Binary Arithmetic Binary addition Binary subtraction
CS 151 Digital Systems Design Lecture 3 More Number Systems.
Assembly Language and Computer Architecture Using C++ and Java
Agenda Shortcuts converting among numbering systems –Binary to Hex / Hex to Binary –Binary to Octal / Octal to Binary Signed and unsigned binary numbers.
1 Binary Arithmetic, Subtraction The rules for binary arithmetic are: = 0, carry = = 1, carry = = 1, carry = = 0, carry =
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.
Two’s Complement 1.As an action: (Assume the starting value is 1011) 1.Flip the bits from the starting value => Add one to get the answer.
1 Binary Numbers Again Recall that N binary digits (N bits) can represent unsigned integers from 0 to 2 N bits = 0 to 15 8 bits = 0 to bits.
Introduction to Number Systems
© 2010 Kettering University, All rights reserved..
1 Lecture 2: Number Systems Binary numbers Base conversion Arithmetic Number systems  Sign and magnitude  Ones-complement  Twos-complement Binary-coded.
Data Representation Number Systems.
Computer Organization & Programming Chapter2 Number Representation and Logic Operations.
Simple Data Type Representation and conversion of numbers
ES 244: Digital Logic Design Chapter 1 Chapter 1: Introduction Uchechukwu Ofoegbu Temple University.
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.
#1 Lec # 2 Winter EECC341 - Shaaban Positional Number Systems A number system consists of an order set of symbols (digits) with relations.
1 Digital Systems and Binary Numbers EE 208 – Logic Design Chapter 1 Sohaib Majzoub.
Number Representation. 10/12/2015CDA31002 Conversion between Representations Now we can represent a quantity in different number representations How can.
1 Digital Design: Number Systems Credits : Slides adapted from: J.F. Wakerly, Digital Design, 4/e, Prentice Hall, 2006 C.H. Roth, Fundamentals of Logic.
46 Number Systems Problem: Implement simple pocket calculator Need: Display, adders & subtractors, inputs Display: Seven segment displays Inputs: Switches.
Lecture 4 Last Lecture –Positional Numbering Systems –Converting Between Bases Today’s Topics –Signed Integer Representation Signed magnitude One’s complement.
BR 8/99 Binary Numbers Again Recall than N binary digits (N bits) can represent unsigned integers from 0 to 2 N bits = 0 to 15 8 bits = 0 to 255.
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.
ECE 2110: Introduction to Digital Systems Signed Addition/Subtraction.
Operations on Bits Arithmetic Operations Logic Operations
Microcomputers I - Electrical and Computer Engineering Dept. at Kettering.
Number Systems and Logic Prepared by Dr P Marais (Modified by D Burford)
Computer Math CPS120 Introduction to Computer Science Lecture 4.
07/12/ Data Representation Two’s Complement & Binary Arithmetic.
Digital Representations ME 4611 Binary Representation Only two states (0 and 1) Easy to implement electronically %0= (0) 10 %1= (1) 10 %10= (2) 10 %11=
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.
CEC 220 Digital Circuit Design Binary Arithmetic & Negative Numbers Monday, January 13 CEC 220 Digital Circuit Design Slide 1 of 14.
CEC 220 Digital Circuit Design Binary Arithmetic & Negative Numbers Fri, Aug 28 CEC 220 Digital Circuit Design Slide 1 of 14.
2’s Complement Another system that lets us represent negative numbers
ECE 171 Digital Circuits Chapter 2 Binary Arithmetic Herbert G. Mayer, PSU Status 1/14/2016 Copied with Permission from prof. Mark PSU ECE.
In decimal we are quite familiar with placing a “-” sign in front of a number to denote that it is negative The same is true for binary numbers a computer.
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.
Computer Organization 1 Data Representation Negative Integers.
Number Systems. Topics  The Decimal Number System  The Binary Number System  Converting from Binary to Decimal  Converting from Decimal to Binary.
Bits, Data types, and Operations: Chapter 2 COMP 2610 Dr. James Money COMP
ECE 3110: Introduction to Digital Systems Signed Number Conversions and operations.
Lecture No. 4 Computer Logic Design. Negative Number Representation 3 Options –Sign-magnitude –One’s Complement –Two’s Complement  used in computers.
{ Binary “There are 10 types of people in the world: Those who understand binary, and those who don't.”
COSC2410: LAB 2 BINARY ARITHMETIC SIGNED NUMBERS FLOATING POINT REPRESENTATION BOOLEAN ALGEBRA 1.
11001 / 101, / ) Perform subtraction on the given unsigned binary numbers using the 2's complement of the subtrahend. Where the result.
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.
Binary & Hex Review.
Addition and Subtraction
Data Representation.
Negative Binary Numbers
Integer Real Numbers Character Boolean Memory Address CPU Data Types
11001 / 101 , / ) Perform subtraction on the given unsigned binary numbers using the 2's complement of the subtrahend. Where the.
Data Representation Integers
Lecture 2 Topics Binary Arithmetic (Unsigned binary operands)
Negative Binary Numbers
Lesson objectives Understand how computers represent and manipulate numbers [unsigned integers, signed integers (sign and magnitude, Two’s complement)
Addition and Substraction
Number Representation
ECEG-3202 Computer Architecture and Organization
CPS120: Introduction to Computer Science
Decimal and binary representation systems
Number Systems Rayat Shikshan Sanstha’s
Number Systems Rayat Shikshan Sanstha’s
Binary & Hex Review.
Presentation transcript:

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 : easy o Negative numbers (2’s complement): - 4 in 4 bits : in 5 bits : Why is this useful? 1. Actual sign extension 2. Binary to decimal conversion (2’s complement) -- can forget about leading 1’s e.g two = 110 two = -2 ten

Negative Binary to Decimal n Change sign (2’s compliment) two = two = - 76 Changing sign What pattern appears at the right end ? 1 followed by some (or no) 0’s o Trick: retain that pattern and flip everything to the left of it e.g =

A Feel for Base 2 n What is multiplication by 2 ? 5 x 2 = 10 ten 101 two x 2 = ? (can you use this in efficiently solving 4.11?) n What is division by 2, ignoring any remainder? two / 2 = ? two / 2 = ? n What does a multiple of 4 look like? 4 = = = All end in 2 zeros. Why?

“Translate Binary to Hexadecimal” n Binary and Hex are two different representations n Can convert from one to the other treating numbers as a series of bits n Need not worry about signed/unsigned, 2’s complement, 1’s complement, etc n Make groups of 4 bits, starting from the right n Add 0’s to the left if necessary (do not sign extend) n Translate each group of 4 bits to hex individually e.g two = two = 1c25 hex

“Bits have no inherent meaning” n “Value” of a binary number depends on how you look at it n e.g. consider the 4 bit number 1110 two n unsigned:14 n signed:??? (can assume 2’s complement) n 2’s complement :- (0010 two ) = -2 n 1’s complement:- (0001 two ) = -1 n sign and magnitude:- (110 two ) = -6

Overflow and Underflow n Assume 4 bit numbers in 2’s complement form n Range : to ( ), or - 8 to 7 n = 12 ……… cannot represent 12 using 4 bits (signed) ! n What happens in binary addition ? 0111(7) (5) = 1100(-4) The number “appears” to be negative because it is out of range n Similarly, 7 - (-5) = 12 ……. out of range n Underflow: (-7) + (-5) = -12 ……. negative number out of range n Remember : overflow/underflow can occur only when 1. Numbers of same sign are added 2. Numbers of opposite signs are subtracted