Dr.Faisal Alzyoud 2/20/2018 Binary Arithmetic.

Slides:



Advertisements
Similar presentations
Computer Engineering FloatingPoint page 1 Floating Point Number system corresponding to the decimal notation 1,837 * 10 significand exponent A great number.
Advertisements

Floating Point Numbers
Floating Point Numbers
Chapter3 Fixed Point Representation Dr. Bernard Chen Ph.D. University of Central Arkansas Spring 2009.
The Binary Number System
Data Representation Number Systems.
Computer Organization and Architecture Computer Arithmetic Chapter 9.
Computer Arithmetic Nizamettin AYDIN
Computer Arithmetic. Instruction Formats Layout of bits in an instruction Includes opcode Includes (implicit or explicit) operand(s) Usually more than.
Computer Arithmetic.
1 Lecture 5 Floating Point Numbers ITEC 1000 “Introduction to Information Technology”
Computer Engineering FloatingPoint page 1 Floating Point Number system corresponding to the decimal notation 1,837 * 10 significand exponent A great number.
CS1Q Computer Systems Lecture 2 Simon Gay. Lecture 2CS1Q Computer Systems - Simon Gay2 Binary Numbers We’ll look at some details of the representation.
PHY 201 (Blum)1 Shift registers and Floating Point Numbers Chapter 11 in Tokheim.
CS 232: Computer Architecture II Prof. Laxmikant (Sanjay) Kale Floating point arithmetic.
1 CE 454 Computer Architecture Lecture 4 Ahmed Ezzat The Digital Logic, Ch-3.1.
Floating Point Arithmetic – Part I
Chapter 9 Computer Arithmetic
William Stallings Computer Organization and Architecture 8th Edition
Floating Point Numbers
Floating Point Representations
CS2100 Computer Organisation
Fundamentals of Computer Science
Unit 1 Introduction Number Systems and Conversion.
A brief comparison of integer and double representation
Introduction To Computer Science
Number Systems and Binary Arithmetic
Digital Logic & Design Dr. Waseem Ikram Lecture 02.
Digital Systems and Number Systems
Integer Division.
Floating Point Number system corresponding to the decimal notation
CS 232: Computer Architecture II
William Stallings Computer Organization and Architecture 7th Edition
IT 0213: INTRODUCTION TO COMPUTER ARCHITECTURE
CS1010 Programming Methodology
Data Structures Mohammed Thajeel To the second year students
Luddy Harrison CS433G Spring 2007
Binary Numbers Material on Data Representation can be found in Chapter 2 of Computer Architecture (Nicholas Carter) CSC 370 (Blum)
Chapter 2 Bits, Data Types & Operations Integer Representation
Shift registers and Floating Point Numbers
Number Representations
Data Representation Data Types Complements Fixed Point Representation
King Fahd University of Petroleum and Minerals
(Part 3-Floating Point Arithmetic)
Computer Science 210 Computer Organization
Data Representation in Computer Systems
Arithmetic Logical Unit
How to represent real numbers
Digital Logic & Design Lecture 02.
ECEG-3202 Computer Architecture and Organization
Computer Architecture
Chapter 8 Computer Arithmetic
Binary to Decimal Conversion
Copyright © Cengage Learning. All rights reserved.
Floating Point Numbers
Shift registers and Floating Point Numbers
Chapter3 Fixed Point Representation
Number Representations
Lecture 9: Shift, Mult, Div Fixed & Floating Point
Presentation transcript:

Dr.Faisal Alzyoud 2/20/2018 Binary Arithmetic

Dr.Faisal Alzyoud 2/20/2018 Addition The addition of two binary numbers is carried out in much the same fashion as in the case of decimal numbers. Example: Calculate the addition of (1003)10 and (501)10 using binary numbers addition. Solution: Summation (Si) = 1 whenever the triple (Ci, Ai, Bi) contains a single 1 or three 1’s. Otherwise Si = 0. Carry digit Ci+1 = 1 whenever at least two of the triple (Ci, Ai, Bi) are 1’s.

Dr.Faisal Alzyoud 2/20/2018 Subtraction Borrowing scheme can be used in binary number subtraction, but it needs the design of a separate logic circuit to do subtraction. Example: Negative numbers can be applied to use addition to perform subtraction. There are several mechanisms available to represent negative numbers to avoid the use of the ‘-‘ sign. The simplest is to add a leading digit where 0 stands for a positive number and 1 for a negative number.

Dr.Faisal Alzyoud 2/20/2018 The leading digit method is used for the storage of numbers, it is not very useful for arithmetic operations, as it would be necessary to treat the leading digit differently from the others. The two main techniques are first, the “two’s complement”, and second, “biasing”. Two’s complement method permits logic circuits designed for addition to be used for subtraction or the addition of negative numbers. Biasing is used for storing negative exponents as part of the IEEE 754 format. The representation of negative numbers and vice-versa will always work through using “one’s complement” followed by two’s complement.

Dr.Faisal Alzyoud 2/20/2018 One’s complement can be carried out using logic gates known as inverters (which simply switch each bit, from 0 to 1, or from 1 to 0). Addition circuitry is used to convert one’s complement to two’s complement. For example, the binary representation of (43)10, in an 8-bit register, is (00101011)2. Its 1’s complement is: (11111111)2 – (00101011)2 = (11010100)2 . The problem with 1’s complement is that the addition of a number with its complement gives all 1’s (e.g. %11111111), instead of 0 (e.g. %00000000), which would be much more desirable.

Dr.Faisal Alzyoud 2/20/2018 Two’s complement: It is similar to the 10’s complement in decimal arithmetic, one obtains 2’s complement of a binary number by first taking 1’s complement, then adding 1. For example, the 2’s complement of (0010 1011)2 is (1101 0100)2 + (0000 0001)2, which is (1101 0101) 2.

Dr.Faisal Alzyoud 2/20/2018 Examples Ex 1. Assuming 8-bit words, use two’s complement to compute 112– 61 = 51, and 61-112 = -51 Solution: First, we have that (112)10 = (0111 0000)2 and (61)10 = (0011 1101)2. The one’s complement of (61)2 = (00111101 )2 is (11000010)2 and its two’s complement is (1100 0011)2. We now add the two numbers to get, after discarding the 9th left-most digit, (00110011)2 = (51)10. The two’s complement representation for –112 is (10010000)2.The representation for 61 is (00111101)2. Adding the two numbers gives:

Dr.Faisal Alzyoud 2/20/2018

Dr.Faisal Alzyoud 2/20/2018 Multiplication In decimal, multiplication relies on the fact that shifting the digits one place to the left (with respect to the decimal point), corresponds to multiplying by 10. In binary, multiplication is carried out in a similar series of multiply, shift and add operations. In binary, shifting the bits one place to the left (with respect to the binary point), corresponds to multiplying by 2. Example: multiply 19 by 13

Dr.Faisal Alzyoud 2/20/2018 Solution: The multiplication operation requires only one new operation beyond the full adder, namely to recognize that 1*1 = 1 and that 0*1 = 1*0 = 0*0 = 0. Faster multipliers are achieved by having a series of interconnected full adders, multipliers and shifters thus reducing the amount of software

Dr.Faisal Alzyoud 2/20/2018 In general, to house the product of two binary numbers having i bits, and j bits, respectively, one needs a result register of at least (i+j) bits. Examples: (111)2 x (111)2 = (110001)2 (3 bits x 3 bits 6 bits) (11111)2 x (11111)2 = (1111000001) 2 (5 bits x 5 bits 10 bits) (8 bits x 4bits 12 bits) In computers, multiplication of integers where one or both of the numbers is/are negative, is handled by using 2’s-complement.

Dr.Faisal Alzyoud 2/20/2018 Division Binary division can be done in a similar way of decimal long-division by dropping 0’s until the desired precision in the result has been reached. Example: calculate 247/13

Scientific Notation and the IEEE 754 Floating-Point Standard Dr.Faisal Alzyoud 2/20/2018 Scientific Notation and the IEEE 754 Floating-Point Standard Floating point numbers allow very large and very small numbers to be represented using only a few digits, at the expense of precision. The precision is primarily determined by the number of digits in the fraction (or significant, which has integer and fractional parts), and the range is primarily determined by the number of digits in the exponent.

Scientific (Floating Point) Notation Dr.Faisal Alzyoud 2/20/2018 Scientific (Floating Point) Notation Scientific notation follows the conventions of decimal notation and is used in computing to carry out “floating point” arithmetic. In decimal notation, a number such as 226.25 is expressed in scientific notation as 2.2625*102. The portion 2.2625 is known as the significant and the power of 10 as the exponent. Example 1: (226.25)10 = (11100010.01)2 to express it in scientific notation, we move the “binary (no longer decimal) point” seven spaces to the left to obtain 226.25 = (1.110001001)2*27, or (1.110001001)*2(111)2 Example 2: (173.4)10=(10101101.011001)2

The IEEE 754 Floating-Point Standard Dr.Faisal Alzyoud 2/20/2018 The IEEE 754 Floating-Point Standard Single Precision The standard word length used (for “single precision”) is 32 bits. One bit is used for the sign, s, (0 for positive numbers and 1 for negative numbers), 8 bits for the exponent, E, and 23 bits for the significant (or mantissa). The procedure used for storing negative and positive exponents is called biasing. This is achieved by adding 127 (the maximum number which can be represented in 8-1=7 bits) to the exponent of 2. (Note: this is not the same as 1’s complement.) The biased exponents 255 = (11111111)2 and 0 = (00000000)2 are reserved for special purposes as given below

Dr.Faisal Alzyoud 2/20/2018 Double Precision Here two 32-bit words are used or a single 64-bit word, distributed as follows: Sign bit: 1-bit, Exponent: 11 bits (bias is 1023, represented by 10 bits), Significant: 52 bits. This significantly increases the range of numbers which can be considered to the order of 10±308 and the accuracy of the significant which can now be trusted up to the 15th decimal place. Advantage and disadvantage of the IEEE 754 format Advantage: The exponent-biasing scheme allows easy sorting of numbers by size. Disadvantage: Numbers must be converted before arithmetic operations can be carried out. Why did IEEE choose this format? Probably because most calls on the arithmetic unit involve sorting as opposed to arithmetic operations. HW1: Represent the following decimal numbers in the IEEE 754 format: 8.5*2-128 , 4.375* 2-137. HW2: Find the IEEE 754 single precision floating-point representation of -0.21875.

Dr.Faisal Alzyoud 2/20/2018

Dr.Faisal Alzyoud 2/20/2018

Dr.Faisal Alzyoud 2/20/2018