CHAPTER 3 Arithmetic For Computers 1/31/2009 1. Topics for discussion 1/31/2009 2 Number system: { radix/base, a set of distinct digits, operations} Radix.

Slides:



Advertisements
Similar presentations
Chapter 3 Arithmetic for Computers. Exam 1 CSCE
Advertisements

CSCE 212 Chapter 3: Arithmetic for Computers Instructor: Jason D. Bakos.
HEXADECIMAL NUMBERS Code
Lecture - 2 Number systems and computer data formats
Company LOGO Edit your slogan here DKT 122/3 DIGITAL SYSTEM 1 WEEK #3 NUMBER SYSTEMS, OPERATION & CODES (PART 2)
Arithmetic CPSC 321 Computer Architecture Andreas Klappenecker.
CS 151 Digital Systems Design Lecture 3 More Number Systems.
M68K Assembly Language Programming Bob Britton Chapter 4 Number Systems.
Arithmetic I CPSC 321 Andreas Klappenecker. Administrative Issues Office hours of TA Praveen Bhojwani: M 1:00pm-3:00pm.
1 Lecture 7: Computer Arithmetic Today’s topics:  Chapter 2 wrap-up  Numerical representations  Addition and subtraction Reminder: Assignment 3 will.
CSCE 211: Digital Logic Design Chin-Tser Huang University of South Carolina.
ENGIN112 L3: More Number Systems September 8, 2003 ENGIN 112 Intro to Electrical and Computer Engineering Lecture 3 More Number Systems.
S. Barua – CPSC 240 CHAPTER 2 BITS, DATA TYPES, & OPERATIONS Topics to be covered are Number systems.
Number System and Codes
Number Systems Computer Science 210 Computer Organization.
1.6 Signed Binary Numbers.
Arithmetic for Computers
EKT 121 / 4 ELEKTRONIK DIGIT 1 CHAPTER 1 : INTRODUCTION.
1 CS/COE0447 Computer Organization & Assembly Language Chapter 3.
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.
1 Digital Technology and Computer Fundamentals Chapter 1 Data Representation and Numbering Systems.
Chapter 3 Data Representation
1 Digital Systems and Binary Numbers EE 208 – Logic Design Chapter 1 Sohaib Majzoub.
ECEN2102 Digital Logic Design Lecture 1 Numbers Systems Abdullah Said Alkalbani University of Buraimi.
Number Systems Spring Semester 2013Programming and Data Structure1.
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,
1 EENG 2710 Chapter 1 Number Systems and Codes. 2 Chapter 1 Homework 1.1c, 1.2c, 1.3c, 1.4e, 1.5e, 1.6c, 1.7e, 1.8a, 1.9a, 1.10b, 1.13a, 1.19.
ECE 301 – Digital Electronics Unsigned and Signed Numbers, Binary Arithmetic of Signed Numbers, and Binary Codes (Lecture #2)
Summer 2012ETE Digital Electronics1 Binary Arithmetic of Signed Binary Numbers.
Introduction to Computing Dr. Nadeem A Khan. Lecture 10.
CPS120: Introduction to Computer Science Computer Math: Converting to Decimal.
ECE 2110: Introduction to Digital Systems Signed Addition/Subtraction.
Operations on Bits Arithmetic Operations Logic Operations
CS Data representation 1 Ch. 2.1 Data Representation Unsigned and Signed Integers – representation, addition, subtraction.
Computer Math CPS120 Introduction to Computer Science Lecture 4.
Ch3a- 2 EE/CS/CPE Computer Organization  Seattle Pacific University Crunching Numbers Topics we need to explore Representing numbers on a computer.
Introduction to Microprocessors Chapter 2. Decimal or Base 10 Numbers  Have ten different digits (0-9)  It is a weighted number system. Each position.
Digital Fundamentals Tenth Edition Floyd Chapter 2 © 2008 Pearson Education.
NUMBER SYSTEMS AND CODES. CS Digital LogicNumber Systems and Codes2 Outline Number systems –Number notations –Arithmetic –Base conversions –Signed.
1 Digital Logic Design Lecture 2 More Number Systems/Complements.
CCE Department – Faculty of engineering - Islamic University of Lebanon Chapter 6 Binary Arithmetic.
Computer Arthmetic Chapter Four P&H. Data Representation Why do we not encode numbers as strings of ASCII digits inside computers? What is overflow when.
Lecture 1.2 (Chapter 1) Prepared by Dr. Lamiaa Elshenawy
Nguyen Le CS147.  2.4 Signed Integer Representation  – Signed Magnitude  – Complement Systems  – Unsigned Versus Signed Numbers.
Computer Math CPS120 Introduction to Computer Science Lecture 7.
11001 / 101, / ) Perform subtraction on the given unsigned binary numbers using the 2's complement of the subtrahend. Where the result.
Computer Representation of Information
Data Representation COE 308 Computer Architecture
Computer Arthmetic Chapter Four P&H.
Addition and Subtraction
Programming and Data Structure
Data Representation ICS 233
Data Representation.
Number Representation
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.
CHAPTER 1 : INTRODUCTION
Chapter 3 Data Representation
Lecture 2 Topics Binary Arithmetic (Unsigned binary operands)
The University of Adelaide, School of Computer Science
Data Representation Data Types Complements Fixed Point Representation
Data Representation in Computer Systems
CS/COE0447 Computer Organization & Assembly Language
CS/COE0447 Computer Organization & Assembly Language
A 1-Bit Arithmetic Logic Unit
ECE 331 – Digital System Design
COMS 361 Computer Organization
Computer Architecture CST 250
Data Representation COE 308 Computer Architecture
Presentation transcript:

CHAPTER 3 Arithmetic For Computers 1/31/2009 1

Topics for discussion 1/31/ Number system: { radix/base, a set of distinct digits, operations} Radix conversion ASCII versus binary representation Signed arithmetic; sign extension Bounds check; validation Addition and subtraction algorithms Multiplication algorithms Floating point representation Floating point arithmetic algorithms

Number system 1/31/ Radix or Base: 10 for decimal system, 2 for binary system, 8 for octal, 12 for duo-decimal (to count dozens), 16 for hexa-decimal Decimal digits: {0,1,2,3,4,5,6,7,8,9} Binary {0,1}: binary digit is a “bit” Octal {0,1,2,3,4,5,6,7} Hex {0,..9, A, B, C, D, E, F} If we assume digits are number from right to left starting from 0 th digit as the least significant digit (Little Endian), the value of the i th digit d in is: d x base i Example: Your pay is $101 per hour. Would you prefer it (the base) in decimal, octal, hexadecimal or binary?

Number Representation 1/31/ On the keyboard it is represented by ASCII: American Standard Code for Information Interchange: 7 bit code represented by a byte container. For character representation this is a nice system. How efficient is this representing numbers for processing? Consider 4 ASCII digits. What is the range of integers you can represent with this?  0 – 9999  4 X 8 = 32 bits With 32 bits and binary systems and only positive numbers:  0 – ( ). What is this value? Approx: 4,000,000,000 or 4G !

Signed Numbers 1/31/ When we allow negative and positive numbers, half the range is occupied by positive numbers and the other by negative numbers. How to represent the sign? Using a bit ? 0 for positive and 1 for negative? Then with 32 bits: + 0 to +( ) positive range - 0 to –( ) negative range A better representation for negative number is 2’s complement. How to compute 2’s complement? What’s the advantage of 2’s complement?  Subtraction is equivalent to adding 2’s complement of the second operand.  Sign extension can be used to extend the number from, from 16 bits to 32 bits for example.

Dealing with Overflow 1/31/ OperationOperand AOperand BResult indicating overflow A + B>= 0 < 0 A + B< 0 > = 0 A - B>= 0< 0 A - B< 0>= 0> 0

Dealing with overflow 1/31/ Signed operations that result in overflow cause an exception whereas unsigned operations on overflow do not cause exception. Example:  add, addi, sub will cause exception on overflow  addu, addiu, and subu will not cause exception on overflow How to detect overflow in unsigned then? addu $t0,$t1,$t2 xor $t3,$t1,$t2 # check if signs differ slt $t3,$t3,$zero # signs differ? bne $t3,$zero,No_Overflow # signs differ nop # signs area same xor $t3,$t0,$t1 # find sign of sum slt $t3,$t3,$zero # if sum sign is diff bne $t3,$zero,Overflow

Branches and Jumps 1/31/ beq $s1,$s2,lab1 # if $s1 == $s2 jump to label lab1 bne $s1,$s2,lab2 # if $s1 ≠ $s2 jump to label lab2 j lab3 # unconditional jump to lab3 jal proc3 # jump and link to proc3 jr retAddr # jump back to callee beqz $s2, lab4 # is $s2 == 0 then jump to lab4