Binary Arithmetic Kuliah Sistem Digital, Teknik Elektro UMY (Rahmat Adiprasetya)

Slides:



Advertisements
Similar presentations
HEXADECIMAL NUMBERS Code
Advertisements

2-1 Chapter 2 - Data Representation Computer Architecture and Organization by M. Murdocca and V. Heuring © 2007 M. Murdocca and V. Heuring Computer Architecture.
Chapter 2: Data Representation
Principles of Computer Architecture Miles Murdocca and Vincent Heuring Chapter 2: Data Representation.
COE 202: Digital Logic Design Signed Numbers
CS 151 Digital Systems Design Lecture 3 More Number Systems.
Assembly Language and Computer Architecture Using C++ and Java
Number Systems Standard positional representation of 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 =
ECE 331 – Digital System Design
Copyright 2008 Koren ECE666/Koren Part.6a.1 Israel Koren Spring 2008 UNIVERSITY OF MASSACHUSETTS Dept. of Electrical & Computer Engineering Digital Computer.
DIGITAL SYSTEMS TCE1111 Representation and Arithmetic Operations with Signed Numbers Week 6 and 7 (Lecture 1 of 2)
ENGIN112 L3: More Number Systems September 8, 2003 ENGIN 112 Intro to Electrical and Computer Engineering Lecture 3 More Number Systems.
Computer ArchitectureFall 2007 © August 29, 2007 Karem Sakallah CS 447 – Computer Architecture.
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
NEGATIVE BINARY NUMBER – Digital Circuit 1 Choopan Rattanapoka.
Binary Representation and Computer Arithmetic
The Binary Number System
Data Representation Number Systems.
Arithmetic for Computers
ACOE1611 Data Representation and Numbering Systems Dr. Costas Kyriacou and Dr. Konstantinos Tatas.
1 Arithmetic and Logical Operations - Part II. Unsigned Numbers Addition in unsigned numbers is the same regardless of the base. Given a pair of bit sequences.
Number Systems Binary and Hexadecimal. Base 2 a.k.a. Binary  Binary works off of base of 2 instead of a base 10 like what we are taught in school 
Numeral Systems Subjects: Numeral System Positional systems Decimal
Data Representation – Binary Numbers
EKT 121 / 4 ELEKTRONIK DIGIT 1 CHAPTER 1 : INTRODUCTION.
General Fixed Radix Number Systems Nonredundant Positive radix, ß n digits in digit set Vector:
Computer Arithmetic Nizamettin AYDIN
Binary Arithmetic Stephen Boyd March 14, Two's Complement Most significant bit represents sign. 0 = positive 1 = negative Positive numbers behave.
Chapter 7 Arithmetic Operations and Circuits Binary Arithmetic Addition –When the sum exceeds 1, carry a 1 over to the next-more-significant column.
#1 Lec # 2 Winter EECC341 - Shaaban Positional Number Systems A number system consists of an order set of symbols (digits) with relations.
2-1 Chapter 2 - Data Representation Principles of Computer Architecture by M. Murdocca and V. Heuring © 1999 M. Murdocca and V. Heuring Principles of Computer.
Dale & Lewis Chapter 3 Data Representation. Data and computers Everything inside a computer is stored as patterns of 0s and 1s Numbers, text, audio, video,
Lecture Overview Introduction Positional Numbering System
Lec 3: Data Representation Computer Organization & Assembly Language Programming.
Digital Logic Design Lecture 3 Complements, Number Codes and Registers.
CH09 Computer Arithmetic  CPU combines of ALU and Control Unit, this chapter discusses ALU The Arithmetic and Logic Unit (ALU) Number Systems Integer.
Number Systems. Why binary numbers? Digital systems process information in binary form. That is using 0s and 1s (LOW and HIGH, 0v and 5v). Digital designer.
CPS120: Introduction to Computer Science Computer Math: Signed Numbers.
Information Representation. Digital Hardware Systems Digital Systems Digital vs. Analog Waveforms Analog: values vary over a broad range continuously.
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.
Engineering 1040: Mechanisms & Electric Circuits Spring 2014 Number Systems.
Computer Arithmetic and the Arithmetic Unit Lesson 2 - Ioan Despi.
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.
ECE 2110: Introduction to Digital Systems Signed Addition/Subtraction.
AEEE2031 Data Representation and Numbering Systems.
Number Systems by Dr. Amin Danial Asham. References  Programmable Controllers- Theory and Implementation, 2nd Edition, L.A. Bryan and E.A. Bryan.
CS1Q Computer Systems Lecture 2 Simon Gay. Lecture 2CS1Q Computer Systems - Simon Gay2 Binary Numbers We’ll look at some details of the representation.
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.
1 Digital Logic Design Lecture 2 More Number Systems/Complements.
Negative Integers Unsigned binary representation can not be used to represent negative numbers. With paper and pencil arithmetic, a number is made negative.
ECE DIGITAL LOGIC LECTURE 3: DIGITAL COMPUTER AND NUMBER SYSTEMS Assistant Prof. Fareena Saqib Florida Institute of Technology Fall 2016, 01/19/2016.
1 CS 151 : Digital Design Chapter 4: Arithmetic Functions and Circuits 4-3 : Binary Subtraction.
ECE DIGITAL LOGIC LECTURE 15: COMBINATIONAL CIRCUITS Assistant Prof. Fareena Saqib Florida Institute of Technology Fall 2015, 10/20/2015.
Integer Operations Computer Organization and Assembly Language: Module 5.
Lecture No. 4 Computer Logic Design. Negative Number Representation 3 Options –Sign-magnitude –One’s Complement –Two’s Complement  used in computers.
Number Systems. The position of each digit in a weighted number system is assigned a weight based on the base or radix of the system. The radix of decimal.
Binary Addition The simplest arithmetic operation in binary is addition. Adding two single-digit binary numbers is relatively simple, using a form of carrying:
Digital Logic & Design Adil Waheed Lecture 02.
Negative Integers Unsigned binary representation can not be used to represent negative numbers. With paper and pencil arithmetic, a number is made negative.
Digital Logic & Design Dr. Waseem Ikram Lecture 02.
CHAPTER 1 : INTRODUCTION
Data Representation in Computer Systems
Digital Logic & Design Lecture 02.
Binary to Decimal Conversion
Presentation transcript:

Binary Arithmetic Kuliah Sistem Digital, Teknik Elektro UMY (Rahmat Adiprasetya)

Introduction Due to the fact that digital computers are constructed from logic gates that can represent only two states, they are obliged to make use of the binary number system with its two digits: 0 and 1. Unlike calculations on paper where both decimal and binary numbers can be of any size — limited only by the size of your paper, the endurance of your pencil, and your stamina — the numbers manipulated within a computer have to be mapped onto a physical system of logic gates and wires. Thus, the maximum value of a number inside a computer is dictated by the width of its data path; that is, the number of bits used to represent that number.

Unsigned Binary Numbers Unsigned binary numbers can only be used to represent positive values.

Unsigned Binary Numbers (1) Each ‘x’ character represents a single bit; the right-hand bit is known as the least significant bit (LSB) because it represents the smallest value. Similarly, the left hand bit is known as the most significant bit (MSB) because it represents the largest value. In computing it is usual to commence indexing things from zero, so the least significant bit is referred to as bit 0, and the most significant bit (of an 8-bit value) is referred to as bit 7. Every bit can be individually assigned a value of 0 or 1, so a group of 8 bits can be assigned 28 = 256 unique combinations of 0s and 1s. This means that an 8-bit unsigned binary number can be used to represent values in the range 0 10 through

Binary Addition Two binary numbers may be added together using an identical process to that used for decimal addition.

Binary Addition (1)

Binary Addition (2)

Binary Subtraction Unsigned binary numbers may be subtracted from each other using an identical process to that used for decimal subtraction. However, for reasons of efficiency, computers rarely perform subtractions in this manner; instead, these operations are typically performed by means of complement techniques. There are two forms of complement associated with every number system, the radix complement and the diminished radix complement, where radix refers to the base of the number system. Under the decimal (base-10) system, the radix complement is also known as the tens complement and the diminished radix complement is known as the nines complement.

Binary Subtraction (nines complement technique) The advantage of the nines complement technique is that it is never necessary to perform a borrow operation.

Binary Subtraction (tens complement technique) The advantage of the tens complement is that it is not necessary to perform an end-around-carry; any carry-out resulting from the addition of the most significant digits is simply dropped from the final result.

Binary Subtraction (Cont.) Similar techniques may be employed with binary (base-2) numbers, where the radix complement is known as the twos complement and the diminished radix complement is known as the ones complement.

Binary Subtraction (ones complement technique) In fact, it isn’t even necessary to perform a subtraction, because the ones complement of a binary number can be simply generated by inverting all of its bits; that is, by exchanging all the 0s with 1s and vice versa.

Binary Subtraction (twos complement technique)

Binary Subtraction (Cont.) Unfortunately, all of the previous examples will return incorrect results if a larger value is subtracted from a smaller value; that is, for these techniques to work, the final result must be greater than or equal to zero. In the case of unsigned binary numbers, the reason is clear because, by definition, an unsigned binary number can only be used to represent a positive value, but subtracting a larger value from a smaller value results in a negative value. It would obviously be somewhat inconvenient if computers could only be used to generate positive values, so we need some way to represent negative numbers.

Signed Binary Numbers Signed binary numbers can be used to represent both positive and negative values, and they do this in a rather cunning way. In standard decimal arithmetic, negative numbers are typically represented in a form known as sign- magnitude, which means prefixing values with plus or minus signs. However, for reasons of efficiency, computers rarely employ the sign-magnitude form, and instead use the signed binary format, in which the most significant bit is also called the sign bit

Signed Binary Numbers (1)

Signed Binary Numbers (2)

Signed Binary Numbers (3) Now pay attention because this is the clever part: closer investigation reveals that each bit pattern is in fact the twos complement of the other! To put this another way, taking the twos complement of a positive signed binary value returns its negative equivalent and vice versa. The end result is that using signed binary numbers greatly reduces the complexity of operations within a computer.

Signed Binary Numbers (4)

Binary Multiplication One technique for performing multiplication in any number base is by means of repeated addition. However, even though computers can perform millions of operations every second, the repeated addition technique is time-consuming when the values to be multiplied are large. As an alternative, binary numbers may by multiplied together by means of a shift-and-add technique known as Booth’s Algorithm Using Booth’s algorithm, a partial product is generated for every bit in the multiplier. If the value of the multiplier bit is 0, its corresponding partial product consists only of 0s; if the value of the bit is 1, its corresponding partial product is a copy of the multiplicand.

Binary Multiplication (Booth’s Algorithm)

Unfortunately, Booth’s Algorithm only works with unsigned binary values. However, this problem can be overcome by taking the twos complement of any negative values before feeding them into the multiplier. If the signs of the two values are the same, both positive or both negative, then no further action need be taken. However, if the signs are different, then the result returned from the multiplier must be negated by transforming it into its twos complement.