COSC2410: LAB 2 BINARY ARITHMETIC SIGNED NUMBERS FLOATING POINT REPRESENTATION BOOLEAN ALGEBRA 1.

Slides:



Advertisements
Similar presentations
Fixed Point Numbers The binary integer arithmetic you are used to is known by the more general term of Fixed Point arithmetic. Fixed Point means that we.
Advertisements

CENG536 Computer Engineering department Çankaya University.
Topics covered: Floating point arithmetic CSE243: Introduction to Computer Architecture and Hardware/Software Interface.
Binary Arithmetic Binary addition Binary subtraction
Princess Sumaya Univ. Computer Engineering Dept. Chapter 3:
Princess Sumaya Univ. Computer Engineering Dept. Chapter 3: IT Students.
Major Numeric Data Types Unsigned Integers Signed Integer Alphanumeric Data – ASCII & UNICODE Floating Point Numbers.
Assembly Language and Computer Architecture Using C++ and Java
Signed Numbers.
Floating Point Numbers
1 Module 2: Floating-Point Representation. 2 Floating Point Numbers ■ Significant x base exponent ■ Example:
ECE 331 – Digital System Design
DIGITAL SYSTEMS TCE1111 Representation and Arithmetic Operations with Signed Numbers Week 6 and 7 (Lecture 1 of 2)
FIGURES FOR CHAPTER 1 INTRODUCTION NUMBER SYSTEMS AND CONVERSION
School of Computer Science G51CSA 1 Computer Arithmetic.
Chapter 3 Data Representation part2 Dr. Bernard Chen Ph.D. University of Central Arkansas Spring 2010.
NEGATIVE BINARY NUMBER – Digital Circuit 1 Choopan Rattanapoka.
Binary Representation and Computer Arithmetic
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 :
Chapter3 Fixed Point Representation Dr. Bernard Chen Ph.D. University of Central Arkansas Spring 2009.
Data Representation Number Systems.
CSCI-365 Computer Organization Lecture Note: Some slides and/or pictures in the following are adapted from: Computer Organization and Design, Patterson.
Simple Data Type Representation and conversion of numbers
Data Representation – Binary Numbers
Computer Organization and Architecture Computer Arithmetic Chapter 9.
Computer Arithmetic Nizamettin AYDIN
Chapter 7 Arithmetic Operations and Circuits Binary Arithmetic Addition –When the sum exceeds 1, carry a 1 over to the next-more-significant column.
2-1 Chapter 2 - Data Representation Principles of Computer Architecture by M. Murdocca and V. Heuring © 1999 M. Murdocca and V. Heuring Chapter Contents.
NUMBER REPRESENTATION CHAPTER 3 – part 3. ONE’S COMPLEMENT REPRESENTATION CHAPTER 3 – part 3.
Computing Systems Basic arithmetic for computers.
Computer Architecture
Floating Point. Agenda  History  Basic Terms  General representation of floating point  Constructing a simple floating point representation  Floating.
Data Representation in Computer Systems
S. Rawat I.I.T. Kanpur. Floating-point representation IEEE numbers are stored using a kind of scientific notation. ± mantissa * 2 exponent We can represent.
Floating Point (a brief look) We need a way to represent –numbers with fractions, e.g., –very small numbers, e.g., –very large numbers,
Oct. 18, 2007SYSC 2001* - Fall SYSC2001-Ch9.ppt1 See Stallings Chapter 9 Computer Arithmetic.
9.4 FLOATING-POINT REPRESENTATION
CSC 221 Computer Organization and Assembly Language
Integer & Floating Point Representations CDA 3101 Discussion Session 05.
Princess Sumaya Univ. Computer Engineering Dept. Chapter 3:
Data Representation in Computer Systems. 2 Signed Integer Representation The conversions we have so far presented have involved only positive numbers.
Number Systems & Operations
Digital Fundamentals Tenth Edition Floyd Chapter 2 © 2008 Pearson Education.
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
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.
DIGITAL SYSTEMS Number systems & Arithmetic Rudolf Tracht and A.J. Han Vinck.
IT1004: Data Representation and Organization Negative number representation.
©Brooks/Cole, 2003 Chapter 3 Number Representation.
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)
1 Ethics of Computing MONT 113G, Spring 2012 Session 4 Binary Addition.
Lecture No. 4 Computer Logic Design. Negative Number Representation 3 Options –Sign-magnitude –One’s Complement –Two’s Complement  used in computers.
Unit I From Fundamentals of Logic Design by Roth and Kinney.
1 CE 454 Computer Architecture Lecture 4 Ahmed Ezzat The Digital Logic, Ch-3.1.
Floating Point Numbers Dr. Mohsen NASRI College of Computer and Information Sciences, Majmaah University, Al Majmaah
Backgrounder: Binary Math
CHAPTER 9 COMPUTER ARITHMETIC - ALU
Data Representation Binary Numbers Binary Addition
Addition and Substraction
Data Structures Mohammed Thajeel To the second year students
ECEG-3202 Computer Architecture and Organization
CPS120: Introduction to Computer Science
Chapter3 Fixed Point Representation
Presentation transcript:

COSC2410: LAB 2 BINARY ARITHMETIC SIGNED NUMBERS FLOATING POINT REPRESENTATION BOOLEAN ALGEBRA 1

Review Convert from base 10 to 2, 8, Base 2: Base 8: 51 Base 16: 29 2

BINARY ARITHMETIC ADDITION, SUBTRACTION, MULTIPLICATION, DIVISION 3

Binary Arithmetic: Addition and Subtraction Addition = = = = 0 (carry: 1) Subtraction 0 – 0 = 0 0 – 1 = 1 (borrow: 1) 1 – 0 = 1 1 – 1 = 0 4

Binary Addition: Example Note: Incase of adding 3 1’s. Instead of the sum being 0 with a carry of 1, the sum is 1 with a carry of 1. 5

Binary Subtraction: Examples Note: After borrowing from the next digit, 0 becomes 1 0 and not becomes 1 when borrowed from. 6

Binary Addition and Binary Subtraction Practice 1. Add and Subtract 1011 from Add and Subtract 010 from

Binary Arithmetic Multiplication Multiplication  0 x 0 = 0  0 x 1 = 0  1 x 0 = 0  1 x 1 = 1 Note: When multiplying, add two of the partial products at a time to prevent mistakes that my occur from adding many numbers 8

Binary Multiplication Practice 1. Multiply 1001 and Multiply 1101 and Multiply 0001 and Multiply 1010 and

SIGNED NUMBERS 3 WAYS TO REPRESENT 10

Method 1: Sign And Magnitude  Obvious solution: sign and magnitude  define leftmost bit (most significant bit) to be sign!  0 => +(positive), 1 => - (negative)  Rest of bits can be numerical value of number  MIPS uses 32-bit integers. +1then would be:  And - 1 in sign and magnitude would be:

Method 2: 1’s Complement  Complement the bits  Example: 7 10 = =  What is ?

Method 3: 2’s Complement  Method 1: Subtract from 2 n. For Example 3: 0011, n = 4 -3: (2 n ) – 0011 = 1101  Method 2: Complement and add 1 3: : = 1101  The leftmost bit of a signed binary numeral indicates the sign  0 (+), all the bits are the numerical value of number  1 (-), all the bits are inverted then 1 is added to the result ► Remember for positive numbers, just make sure a 0 is the MSB. You do not need to convert it using the formula above! 13

Signed Number Representation Table 14

Signed Number Representation Practice 1. Represent each negative number as an 8 bit binary number using a) sign and magnitude, b) 1’s complement, and c) 2’s complement

Addition/Subtraction using 2’s Complement  Subtraction = Addition with opposite sign. 4 – 6 = 4 + (-6) = -2 4: :1010(2’s complement) Sign bit =-2

Overflow Error: Sum Is Too Large  4 bit binary with 2’s complement representation has a number range between -8 and 7  What happens if 6 + 4? (-7) + (-2)? 6:0110-7:1001 4:0100-2: Sign bit = 1 (negative) Sign bit = 0 (positive)

Overflow Error: Cont’d…  Only 2 cases where overflow can occur:  Sum of 2 positive numbers yields a negative result  Sum of 2 negative numbers yields a positive result  Note: We always ignore the carry to ensure number of bits does not change. 18

2’s Complement Addition/Subtraction Practice Convert the following decimal numbers into 6 bit binary and then solve using 2’s complement. Indicate if Overflow Occurs

IEEE FLOATING POINT REPRESENTATION 20

IEEEFloating Point Representation  Most standard floating point representation use: 1 bit for the sign (positive or negative) 8 bits for the range (exponent field) 23 bits for the precision (fraction field) 21 Note: Biased Notation. The exponent is obtained by adding 127 to the value. That is: 5 -> 132, 1-> 128, 0 -> 127, >0

Floating Point Exceptions Overflow & Underflow  Overflow occurs when the exponent is too large to fit in the exponent field.  Underflow occurs when the exponent is too small to fit in the exponent field. 22 Negative Overflow Negative numbersPositive Numbers Negative UnderflowPositive UnderflowPositive Overflow 0

Floating Point Example  How is the decimal number represented in floating point? Show Steps of your work. 23 Thus the exponent is given by:

Floating Point Example Solution

Floating Point Example 2  Convert the following binary floating point number into decimal FPexponent = = 125

Floating Point Representation Practice  How is the decimal number represented in floating point? Show all steps of your work.  How is the number (17.4) 16 represented in binary floating point? Show all steps of your work.  Represent ( ) 2 as floating point. Show all steps of your work. 26

Floating Point Practice Cont’d… 27  Convert the following binary floating point number into an un-normalized binary number  Convert the following binary floating point number into decimal