Lecture 2 Binary Arithmetic Topics Terminology Fractions Base-r to decimal Unsigned Integers Signed magnitude Two’s complement August 26, 2003 CSCE 211.

Slides:



Advertisements
Similar presentations
DATA REPRESENTATION CONVERSION.
Advertisements

©Brooks/Cole, 2003 Chapter 3 Number Representation.
Assembly Language and Computer Architecture Using C++ and Java
Signed Numbers.
Assembly Language and Computer Architecture Using C++ and Java
Computer ArchitectureFall 2008 © August 25, CS 447 – Computer Architecture Lecture 3 Computer Arithmetic (1)
1 Binary Arithmetic, Subtraction The rules for binary arithmetic are: = 0, carry = = 1, carry = = 1, carry = = 0, carry =
CSCE 211: Digital Logic Design Chin-Tser Huang University of South Carolina.
ECE 331 – Digital System Design
1 CSE-221 Digital Logic Design (DLD) Lecture-1: Digital Systems & Number Systems.
DIGITAL SYSTEMS TCE1111 Representation and Arithmetic Operations with Signed Numbers Week 6 and 7 (Lecture 1 of 2)
Number System and Codes
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.
EE 261 – Introduction to Logic Circuits
FIGURES FOR CHAPTER 1 INTRODUCTION NUMBER SYSTEMS AND CONVERSION
1 Lecture 2: Number Systems Binary numbers Base conversion Arithmetic Number systems  Sign and magnitude  Ones-complement  Twos-complement Binary-coded.
ECE 2110: Introduction to Digital Systems Signed Number Conversions.
Simple Data Type Representation and conversion of numbers
Data Representation – Binary Numbers
Digital Design: From Gates to Intelligent Machines
Conversion Between Lengths Positive number pack with leading zeros +18 = = Negative numbers pack with leading ones -18 =
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.
#1 Lec # 2 Winter EECC341 - Shaaban Positional Number Systems A number system consists of an order set of symbols (digits) with relations.
NUMBER REPRESENTATION CHAPTER 3 – part 3. ONE’S COMPLEMENT REPRESENTATION CHAPTER 3 – part 3.
CHAPTER 1 INTRODUCTION NUMBER SYSTEMS AND CONVERSION.
Lecture 1 Binary Representation Topics Terminology Base 10, Hex, binary Fractions Base-r to decimal Unsigned Integers Signed magnitude Two’s complement.
Integer Conversion Between Decimal and Binary Bases Conversion of decimal to binary more complicated Task accomplished by –Repeated division of decimal.
46 Number Systems Problem: Implement simple pocket calculator Need: Display, adders & subtractors, inputs Display: Seven segment displays Inputs: Switches.
CHAPTER 1 INTRODUCTION NUMBER SYSTEMS AND CONVERSION
Lecture 4 Last Lecture –Positional Numbering Systems –Converting Between Bases Today’s Topics –Signed Integer Representation Signed magnitude One’s complement.
Number Systems ELEC 311 Digital Logic and Circuits Dr. Ron Hayne Images Courtesy of Cengage Learning.
IKI Data Types & Representations Bobby Nazief Semester-I The materials on these slides are adopted from those in CS231’s Lecture Notes.
Computer Arithmetic and the Arithmetic Unit Lesson 2 - Ioan Despi.
ECE 301 – Digital Electronics Unsigned and Signed Numbers, Binary Arithmetic of Signed Numbers, and Binary Codes (Lecture #2)
Number systems, Operations, and Codes
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.
Operations on Bits Arithmetic Operations Logic Operations
WEEK #2 NUMBER SYSTEMS, OPERATION & CODES (PART 1)
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.
Bits, Data types, and Operations: Chapter 2 COMP 2610 Dr. James Money COMP
CEC 220 Digital Circuit Design Binary Arithmetic & Negative Numbers Monday, January 13 CEC 220 Digital Circuit Design Slide 1 of 14.
Outline Binary Addition 2’s complement Binary Subtraction Half Adder
School of Computer and Communication Engineering, UniMAP Mohd ridzuan mohd nor DKT 122/3 - DIGITAL SYSTEM I Chapter.
Lecture 3 Combinational Circuits
Introduction To Number Systems Binary System M. AL-Towaileb1.
CEC 220 Digital Circuit Design Binary Arithmetic & Negative Numbers Fri, Aug 28 CEC 220 Digital Circuit Design Slide 1 of 14.
1 Digital Logic Design Lecture 2 More Number Systems/Complements.
Lecture 2 Number Representation, Overflow and Logic Topics Adders Math Behind Excess-3 Overflow Unsigned, signed-magnitude Two’s Complement Gray Code Boolean.
Chapter 1 Representing Data in a Computer. 1.1 Binary and Hexadecimal Numbers.
Bits, Data types, and Operations: Chapter 2 COMP 2610 Dr. James Money COMP
ECE 2110: Introduction to Digital Systems Number Systems: conversions.
Lecture No. 4 Computer Logic Design. Negative Number Representation 3 Options –Sign-magnitude –One’s Complement –Two’s Complement  used in computers.
1 Integer Representations V1.0 (22/10/2005). 2 Integer Representations  Unsigned integer  Signed integer  Sign and magnitude  Complements  One’s.
Binary & Hex Review.
Digital Systems and Number Systems
Integer Real Numbers Character Boolean Memory Address CPU Data Types
CHAPTER 1 INTRODUCTION NUMBER SYSTEMS AND CONVERSION
CHAPTER 1 : INTRODUCTION
Digital Arithmetic Wen-Hung Liao, Ph.D..
Data Representation in Computer Systems
Binary to Decimal Conversion
Binary & Hex Review.
Introduction To Number Systems
Chapter 1 Introduction.
Presentation transcript:

Lecture 2 Binary Arithmetic Topics Terminology Fractions Base-r to decimal Unsigned Integers Signed magnitude Two’s complement August 26, 2003 CSCE 211 Digital Design

– 2 – CSCE 211H Fall 2003 Overview Last Time: Readings 1.1, Analog vs Digital Conversion Base-r to decimal Conversion decimal to Base-r New: Readings , 3.1 Conversion of Fractions base-r  decimal Unsigned Arithmetic Signed Magnitude Two’s Complement Excess-1023VHDL Introductory Examples

– 3 – CSCE 211H Fall 2003 Review Last Time: Base-r to decimal Converting base-r to decimal by definition d n d n-1 d n-2 …d 2 d 1 d 0 = d n r n + d n-1 r n-1 … d 2 r 2 +d 1 r 1 + d 0 r 0 Example 4F0C = 4* F* * C*16 0 4F0C = 4* F* * C*16 0 = 4* * *1 = =20236

– 4 – CSCE 211H Fall 2003 Review Last Time: decimal to Base-r Repeated division algorithm Justification: d n d n-1 d n-2 …d 2 d 1 d 0 = d n r n + d n-1 r n-1 … d 2 r 2 +d 1 r 1 + d 0 r 0 Dividing each side by r yields (d n d n-1 d n-2 …d 2 d 1 d 0 ) / r = d n r n-1 + d n-1 r n-2 … d 2 r 1 +d 1 r 0 + d 0 r -1 So d 0 is the remainder of the first division ((q 1 ) / r = d n r n-2 + d n-1 r n-3 … d 3 r 1 +d 2 r 0 + d 1 r -1 So d 1 is the remainder of the next division and d 2 is the remainder of the next division …

– 5 – CSCE 211H Fall 2003 Review Last Time: decimal to Base-r Repeated division algorithm Example Convert 4343 to hex 4343/16 = 271 remainder = 7 271/16 = 16 remainder = /16 = 16 remainder = 15 16/16 = 1 remainder = 0 16/16 = 1 remainder = 0 1/16 = 0 remainder = 1 1/16 = 0 remainder = 1 So = 10F7 16 To check the answer convert back to decimal 10F7 = 1* *16 + 7*1 = = 4343

– 6 – CSCE 211H Fall 2003 Review Last Time: Hex to Binary One hex digit = four binary digits Example 3FAC = (spaces just for readability) 3FAC = (spaces just for readability) Binary to hex four digits = one (from right!!!) Example = = = 3 D A

– 7 – CSCE 211H Fall 2003 Hex to Decimal Fractions.d -1 d -2 d -3 …d –(n-2) d –(n-1) d -n = d -1 r -1 + d -2 r -2 …d -(n-1) r -(n-1) +d 1 r -n Example.1EF 16 = 1* E* F*16-3.1EF 16 = 1* E* F*16-3 = 1* * *2.4414e-4 = … (probably close but not right) = … (probably close but not right)

– 8 – CSCE 211H Fall 2003 Decimal Fractions to hex.d -1 d -2 d -3 …d –(n-2) d –(n-1) d -n = d -1 r -1 + d -2 r -2 …d -(n-1) r -(n-1) +d 1 r -n Multiplication by r yields r *(.d -1 r -1 + d -2 r -2 …d -(n-1) r -(n-1) +d 1 r -n = d -1 r 0 + d -2 r -1 …d -(n-1) r -(n-2) +d 1 r -(n-1) Whole number part = d -1 r 0 Multiplying again by r yields d -2 r 0 as the whole number part … till fraction = 0

– 9 – CSCE 211H Fall 2003 Example: Hex Fractions to decimal Convert.3FA to decimal.3FA16 = 3* F* A*16-3.3FA16 = 3* F* A*16-3 = 3* * * (1/4096) =

– 10 – CSCE 211H Fall 2003 Unsigned integers What is the biggest integer representable using n-bits(n digits)? What is its value in decimal? Special cases 8 bits 16 bits 16 bits 32 bits 32 bits

– 11 – CSCE 211H Fall 2003 Arithmetic with Binary Numbers x x 101 Problems with 8 bit operations

– 12 – CSCE 211H Fall 2003 Signed integers How do we represent? Signed-magnitude Excess representations w bits  0 <= unsigned_value < 2 w In excess-B we subtract the bias (B) to get the value. In excess-B we subtract the bias (B) to get the value. example example

– 13 – CSCE 211H Fall 2003 Complement Representations of Signed integers One’s complement Two’s complement

– 14 – CSCE 211H Fall 2003 Two’s Complement Operation One’s complement + 1 or Find rightmost 1, complement all bits to the left of it. Examples

– 15 – CSCE 211H Fall 2003 Two’s Complement Representation Consider a two’s complement binary number d n d n-1 d n-2 …d 2 d 1 d 0 If d n, the sign bit = 0 the number is positive and its magnitude is given by the other bits. If d n, the sign bit = 1 the number is negative and take its two’s complement to get the magnitude. Weighted Sum Interpretation … n-1 2 n-2 n -2 n-1

– 16 – CSCE 211H Fall 2003 Two’s Complement Representation Consider a two’s complement binary number d n d n-1 d n-2 …d 2 d 1 d 0 If d n, the sign bit = 0 the number is positive and its magnitude is given by the other bits. If d n, the sign bit = 1 the number is negative and take its two’s complement to get the magnitude. Weighted Sum 0 1 Example = 1 2 … n-1 2 n-2 n -2 n-1

– 17 – CSCE 211H Fall 2003 Two’s Complement Representation What is the 2’s complement representation in 16 bits of –5? +7?-1?0-2

– 18 – CSCE 211H Fall 2003 Arithmetic with Signed Integers Signed Magnitude Addition if the signs are the same add the magnitude if the signs are different subtract the smaller from the larger and use the sign of the larger if the signs are different subtract the smaller from the larger and use the sign of the largerSubtraction? Two’s complement Just add signs take care of themselves

– 19 – CSCE 211H Fall 2003 Overflow in Two’s Complement

– 20 – CSCE 211H Fall 2003 Binary Code Decimal

– 21 – CSCE 211H Fall 2003 Representations of Characters

– 22 – CSCE 211H Fall 2003 Basic Gates ANDORNOT

– 23 – CSCE 211H Fall 2003 Basic Gates NANDNORXOR

– 24 – CSCE 211H Fall 2003 Half Adder Circuit

– 25 – CSCE 211H Fall 2003 Full Adder