CS/CoE 0447 Subtraction, Multiplication, and Division Examples

Similar documents
Lecture 8: Binary Multiplication & Division

Computer Science 281 Binary and Hexadecimal Review

Decimals Adding and Subtracting

CS201: Architecture and Assembly Language

Oct: 50 8 = 6 (r = 2) 6 8 = 0 (r = 6) Writing the remainders in reverse order we get: (50) 10 = (62) 8

Useful Number Systems

Lecture 2. Binary and Hexadecimal Numbers

Binary Division. Decimal Division. Hardware for Binary Division. Simple 16-bit Divider Circuit

CSI 333 Lecture 1 Number Systems

Binary Number System. 16. Binary Numbers. Base 10 digits: Base 2 digits: 0 1

CDA 3200 Digital Systems. Instructor: Dr. Janusz Zalewski Developed by: Dr. Dahai Guo Spring 2012

Binary Numbers. Binary Octal Hexadecimal

Paramedic Program Pre-Admission Mathematics Test Study Guide

To convert an arbitrary power of 2 into its English equivalent, remember the rules of exponential arithmetic:

NUMBER SYSTEMS. William Stallings

Recall the process used for adding decimal numbers. 1. Place the numbers to be added in vertical format, aligning the decimal points.

COMP 250 Fall 2012 lecture 2 binary representations Sept. 11, 2012

YOU MUST BE ABLE TO DO THE FOLLOWING PROBLEMS WITHOUT A CALCULATOR!

Number of bits needed to address hosts 8

Decimal to Binary Conversion

Positional Numbering System

Levent EREN A-306 Office Phone: INTRODUCTION TO DIGITAL LOGIC

Cyber Security Workshop Encryption Reference Manual

Binary Adders: Half Adders and Full Adders

Systems I: Computer Organization and Architecture

ADDITION. Children should extend the carrying method to numbers with at least four digits.

Implementation of Modified Booth Algorithm (Radix 4) and its Comparison with Booth Algorithm (Radix-2)

Solution Guide Chapter 14 Mixing Fractions, Decimals, and Percents Together

Divide: Paper & Pencil. Computer Architecture ALU Design : Division and Floating Point. Divide algorithm. DIVIDE HARDWARE Version 1

PREPARATION FOR MATH TESTING at CityLab Academy

2.3 IPv4 Address Subnetting Part 2

Classful Subnetting Explained

Classless Subnetting Explained

Number and codes in digital systems

CS101 Lecture 11: Number Systems and Binary Numbers. Aaron Stevens 14 February 2011

1. Give the 16 bit signed (twos complement) representation of the following decimal numbers, and convert to hexadecimal:

2010/9/19. Binary number system. Binary numbers. Outline. Binary to decimal

Sense of Number Visual Calculations Policy

EE 261 Introduction to Logic Circuits. Module #2 Number Systems

FRACTIONS COMMON MISTAKES

COMPSCI 210. Binary Fractions. Agenda & Reading

Exponents, Radicals, and Scientific Notation

AN617. Fixed Point Routines FIXED POINT ARITHMETIC INTRODUCTION. Thi d t t d ith F M k Design Consultant

Today. Binary addition Representing negative numbers. Andrew H. Fagg: Embedded Real- Time Systems: Binary Arithmetic

ASCII and BCD Arithmetic. Chapter 11 S. Dandamudi

Solution for Homework 2

APPENDIX B. Routers route based on the network number. The router that delivers the data packet to the correct destination host uses the host ID.

Chapter 1: Digital Systems and Binary Numbers

Binary Representation. Number Systems. Base 10, Base 2, Base 16. Positional Notation. Conversion of Any Base to Decimal.

TCP/IP Cheat Sheet. A Free Study Guide by Boson Software, LLC

Number Representation

NUMBER SYSTEMS. 1.1 Introduction

Dr Brian Beaudrie pg. 1

Chapter 4: Computer Codes

2011, The McGraw-Hill Companies, Inc. Chapter 3

Session 29 Scientific Notation and Laws of Exponents. If you have ever taken a Chemistry class, you may have encountered the following numbers:

Subnetting Study Guide

Math Content by Strand 1

Addition Methods. Methods Jottings Expanded Compact Examples = 15

Activity 6.7.4: IPv4 Address Subnetting Part 2

DNA Data and Program Representation. Alexandre David

This Unit: Floating Point Arithmetic. CIS 371 Computer Organization and Design. Readings. Floating Point (FP) Numbers

Welcome to Basic Math Skills!

CPEN Digital Logic Design Binary Systems

IT:101 Cisco Networking Academy I Subnetting

HOMEWORK # 2 SOLUTIO

Sheet 7 (Chapter 10)

MATH-0910 Review Concepts (Haugen)

The string of digits in the binary number system represents the quantity

Chapter 3. if 2 a i then location: = i. Page 40

Chapter 2. Binary Values and Number Systems

3 cups ¾ ½ ¼ 2 cups ¾ ½ ¼. 1 cup ¾ ½ ¼. 1 cup. 1 cup ¾ ½ ¼ ¾ ½ ¼. 1 cup. 1 cup ¾ ½ ¼ ¾ ½ ¼

Major Work of the Grade

Chapter 7 Lab - Decimal, Binary, Octal, Hexadecimal Numbering Systems

MEP Y9 Practice Book A

RN-coding of Numbers: New Insights and Some Applications

Chapter 1: Order of Operations, Fractions & Percents

Numeral Systems. The number twenty-five can be represented in many ways: Decimal system (base 10): 25 Roman numerals:

plc numbers Encoded values; BCD and ASCII Error detection; parity, gray code and checksums

Pre-Calculus II Factoring and Operations on Polynomials

1. Convert the following base 10 numbers into 8-bit 2 s complement notation 0, -1, -12

Base Conversion written by Cathy Saxton

Sistemas Digitais I LESI - 2º ano

Activity 1: Using base ten blocks to model operations on decimals

Unsigned Conversions from Decimal or to Decimal and other Number Systems

THE BINARY NUMBER SYSTEM

Goals. Unary Numbers. Decimal Numbers. 3,148 is s 100 s 10 s 1 s. Number Bases 1/12/2009. COMP370 Intro to Computer Architecture 1

Design and FPGA Implementation of a Novel Square Root Evaluator based on Vedic Mathematics

Section 1.4 Place Value Systems of Numeration in Other Bases

Today s topics. Digital Computers. More on binary. Binary Digits (Bits)

Quick Reference ebook

Binary Representation

ECE 0142 Computer Organization. Lecture 3 Floating Point Representations

Numbering Systems. InThisAppendix...

MATHEMATICAL NOTATION COMPARISONS BETWEEN U.S. AND LATIN AMERICAN COUNTRIES

The Euclidean Algorithm

Chapter 4 -- Decimals

Transcription:

CS/CoE 0447 Subtraction, Multiplication, and Division Examples 1. Perform three subtractions on 9-bit 2's complement binary numbers as follows: a) 206 54 b) 68 56 c) 51 76 For each of these subtractions, convert the numbers into 9-bit 2's complement, and for the numbers to subtract, or the negative numbers, convert them to their negative counterpart. Add those numbers and convert the resultant binary 2's complement number into decimal form. Show all your work. a) 206 54 Conversion to 9-bit 2 s Complement +206-54 Notation from Decimal Notation Step 1a. Convert positive part to 011001110-0110110 binary. Step 1b. Include preceding 0. Step 1c. Preserve negative sign, if present. Step 2. If negative sign is present, flip bits and add 1. Not Applicable 1001001 Step 3. Extend sign bit as needed. 011001110 111001010 Decimal Notation Two s Complement Notation 206(decimal) 011001110-54(decimal) 11001010 010011000 152 (decimal)

b) 68 56 Conversion to 9-bit 2 s Complement +68-56 Notation from Decimal Notation Step 1a. Convert positive part to 01000100-0111000 binary. Step 1b. Include preceding 0. Step 1c. Preserve negative sign, if present. Step 2. If negative sign is present, flip bits and add 1. Not Applicable 1000111 Step 3. Extend sign bit as needed. 001000100 111001000 Decimal Notation Two s Complement Notation 68(decimal) 001000100-56(decimal) 11001000 000001100 12 (decimal) c) 51 76 Conversion to 9-bit 2 s Complement -51-76 Notation from Decimal Notation Step 1a. Convert positive part to -0110011-01001100 binary. Step 1b. Include preceding 0. Step 1c. Preserve negative sign, if present. Step 2. If negative sign is present, flip bits and add 1. 1001100 10110011 Step 3. Extend sign bit as needed. 111001101 110110100 Decimal Notation Two s Complement Notation -51(decimal) 111001101-76(decimal) 10110100 110000001-127 (decimal)

2. Show the steps for the multiplication of 10110110b and 10110100b (unsigned) using Hardware Design 3 (http://www.cs.pitt.edu/~childers/cs0447/lectures/numbers3.pdf). Here 10110110b is the multiplicand and 10110100b is the multiplier. Fill up the columns: Itera Multiplicand Implementation 3 -tion Step Product6-bit) 0 10110110b initial values 1011 0100 1 10110110b 1: 0 -> no op 2 10110110b 1: 0 -> no op 3 10110110b 1: 1 -> product = product + multiplicand 4 10110110b 1: 0 -> no op 5 10110110b 1: 1 -> product = product + multiplicand 6 10110110b 1: 1 -> product = product + multiplicand 7 10110110b 1: 0 -> no op 8 10110110b 1: 1 -> product = product + multiplicand 1011 0100 0101 1010 0101 1010 0010 1101 1011 0110 0010 1101 0101 1011 0001 0110 0101 1011 0001 0110 0010 1101 1000 1011 1110 0011 1000 1011 0111 0001 1100 0101 0010 0111 1100 0101 1001 0011 1110 0010 1001 0011 1110 0010 0100 1001 1111 0001 1111 1111 1111 0001 0111 1111 1111 1000 *Shift in carry out bit of Step 1a in the flowchart on page 3 (slide 42) of (http://www.cs.pitt.edu/~childers/cs0447/lectures/numbers3.pdf). If Step 1a is bypassed, shift in 0.

3. Convert the following 8-bit binary numbers into Booth's encoding form: 01001011, 10011101, 01001101 Original: Write Implied 0: Encode each pair: 01001011 010010110 010010110-1 010010110 0 010010110 1 010010110-1 010010110 1 010010110 0 010010110-1 010010110 1 10011101 100111010 100111010-1 100111010 1 100111010-1 100111010 0 100111010 0 100111010 1 100111010 0 100111010-1 01001101 010011010 010011010-1 010011010 1 010011010-1 010011010 0 010011010 1 010011010 0 010011010-1 010011010 1 Booth s encoded: 1-101-110-1 -10100-11-1 1-1010-11-1 4. Convert the following decimal numbers into 9-bit binary numbers in Booth's encoding form: 21, -217, -45 Original (dec.): 21-217 -45 Orig.(9-bit 2 s): Write Implied 0: Encode each pair: 000010101 0000101010 0000101010-1 0000101010 1 0000101010-1 0000101010 1 0000101010-1 0000101010 1 0000101010 0 0000101010 0 0000101010 0 100100111 1001001110 1001001110-1 1001001110 1 1001001110-1 1001001110 1 1001001110-1 111010011 1110100110 1110100110-1 1110100110 1 1110100110-1 1110100110 1 1110100110-1 Booth s encoded: 0001-11-11-1 -101-10100-1 00-11-1010-1 Check by multiplying each Booth s digit by the weight of its place and then adding each product. 256 = 0)+ 128 = 0)+ 64 = 0)+ 32 = 32)+ 16 = -16)+ 8 = 8)+ 4 = -4)+ 2 = 2)+ 1 = -1)= 21 256=-256)+ 128 = 0)+ 64 = 64)+ 32 = -32)+ 16 = 0)+ 8 = 8)+ 4 = 0)+ 2 = 0)+ 1 = -1)= -217 256 = 0)+ 128 = 0)+ 64 = -64)+ 32 = 32)+ 16 = -16)+ 8 = 0)+ 4 = 4)+ 2 = 0)+ 1 = -1)= -45

5. Show the steps for the multiplication of 10110110b and 10110100b (signed) using Booth's algorithm (http://www.cs.pitt.edu/~childers/cs0447/lectures/numbers3.pdf). Here 10110110b (-74decimal) is the multiplicand and 10110100b (-76decimal) is the multiplier. Fill up the columns: Iteration Multiplicand 0 10110110b (-74decimal) Booth's Algorithm Step Product7-bit) initial values 1011 0100 0 1 10110110b 1: 00 -> no op 0101 1010 0 2 10110110b 1: 00 -> no op 0010 1101 0 3 10110110b 4 10110110b 5 10110110b 1: 01 -> product = product + multiplicand 6 10110110b 1: 11 -> no op 7 10110110b 8 10110110b 1: 01 -> product = product + multiplicand +0100 1010 (74 dec.) 0100 1010 0010 1101 0 0010 0101 0001 0110 1 011 0110 (-74 dec.) 1101 1011 0001 0110 1 1110 1101 1000 1011 0 +0100 1010 (74 dec.) 0011 0111 1000 1011 0 0001 1011 1100 0101 1 0001 1011 1100 0101 1 0000 1101 1110 0010 1 011 0110 (-74 dec.) 1100 0011 1110 0010 1 1110 0001 1111 0001 0 +0100 1010 (74 dec.) 0010 1011 1111 0001 0 0001 0101 1111 1000 1 (-74decimal) times (-76decimal) = (5624 decimal = 0001 0101 1111 1000 binary)

6. Show the steps for the multiplication of 00110111b and 10010001b (signed) using Booth's algorithm (available here: http://www.cs.pitt.edu/~childers/cs0447/lectures/numbers3.pdf ). Here 00110111b is the multiplicand and 10010001b is the multiplier. Fill up the columns: Iteration Multiplicand 0 00110111b (55dec) 1 10010001b 00110111b 2 00110111b Booth's Algorithm Step Product7-bit) initial values 1001 0001 0 1: 01 -> product = product + multiplicand 100 1001 (-55 dec.) 1100 1001 1001 0001 0 1110 0100 1100 1000 1 +0011 0111 (55 dec.) 0001 1011 1100 1000 1 0000 1101 1110 0100 0 3 00110111b 1: 00 -> no op 0000 0110 1111 0010 0 4 00110111b 1: 00 -> no op 0000 0011 0111 1001 0 5 00110111b 100 1001 (-55 dec.) 1100 1100 0111 1001 0 1110 0110 0011 1100 1 6 00110111b +0011 0111 (55 dec.) 1: 01 -> product = product + multiplicand 0001 1101 0011 1100 1 0000 1110 1001 1110 0 7 00110111b 1: 00 -> no op 0000 0111 0100 1111 0 8 00110111b 100 1001 (-55 dec.) 1101 0000 0100 1111 0 1110 1000 0010 0111 1 (55decimal) times 11decimal) = -6105 decimal = 1110 1000 0010 0111

7 In a table similar to the following one, show the steps for computing 00101101b (the dividend) divided by 0101b (the divisor, both numbers are unsigned) using non-restoring division. Nonrestoring division is described online at: http://www.cs.pitt.edu/~childers/cs0447/lectures/divisionfloats.pdf. An example of doing non-restoring division is also shown. Iteration Divisor (4 bits) 0 0101 (5 dec) 1 2 3 Step (description) Remainder Register (8 bits) Dividend Register (8 bits) initial values shift left by 1 remainder = remainder divisor 4 5 (remainder 0) shift left; r0=1 6 remainder = remainder divisor 7 8 (remainder 0) shift left; r0=1 Done shift left half of 16-bit remainder dividend register right by 1 +(-5dec) 111 1011 1111 0110 1111 0111 1111 1100 1111 1000 1111 1101 0000 0001 +(-5dec) 111 1011 1111 1100 1111 1000 1111 1101 +(-5dec) 111 1011 0010 1101 (45 dec) 0101 1010 0101 1010 1011 0100 1011 0100 0110 1000 0110 1000 1101 0000 1101 0000 1010 0000 1010 0000 0100 0001 0100 0001 1000 0010 1000 0010 0000 0100 0000 0100 0000 1001 0000 1001 45 / 5 = 9 (decimal) = 1001 (binary) 0