CS/EE1012 INTRODUCTION TO COMPUTER ENGINEERING SPRING 2013 HOMEWORK I. Solve all homework and exam problems as shown in class and sample solutions

Similar documents
Decimal & Binary Representation Systems. Decimal & Binary Representation Systems

Positional notation Ch Conversions between Decimal and Binary. /continued. Binary to Decimal

A complement number system is used to represent positive and negative integers. A complement number system is based on a fixed length representation

Binary Addition. Add the binary numbers and and show the equivalent decimal addition.

Introduction to Computer Science-103. Midterm

Number System. Introduction. Decimal Numbers

Number representations

1010 2?= ?= CS 64 Lecture 2 Data Representation. Decimal Numbers: Base 10. Reading: FLD Digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9

Number Systems Standard positional representation of numbers: An unsigned number with whole and fraction portions is represented as:

CMPE223/CMSE222 Digital Logic Design. Positional representation

Computer Organization

Number Systems. Both numbers are positive

COMP Overview of Tutorial #2

Chapter 1. Digital Systems and Binary Numbers

Signed Binary Numbers

Number Systems and Conversions UNIT 1 NUMBER SYSTEMS & CONVERSIONS. Number Systems (2/2) Number Systems (1/2) Iris Hui-Ru Jiang Spring 2010

Digital Arithmetic. Digital Arithmetic: Operations and Circuits Dr. Farahmand

Rui Wang, Assistant professor Dept. of Information and Communication Tongji University.

Semester Transition Point. EE 109 Unit 11 Binary Arithmetic. Binary Arithmetic ARITHMETIC

T02 Tutorial Slides for Week 2

MC1601 Computer Organization

CHW 261: Logic Design

Basic Arithmetic (adding and subtracting)

Digital Fundamentals. CHAPTER 2 Number Systems, Operations, and Codes

DLD VIDYA SAGAR P. potharajuvidyasagar.wordpress.com. Vignana Bharathi Institute of Technology UNIT 1 DLD P VIDYA SAGAR

Data Representation COE 301. Computer Organization Prof. Muhamed Mudawar

UNCA CSCI 255 Exam 1 Spring February, This is a closed book and closed notes exam. It is to be turned in by 1:45 PM.

THE LOGIC OF COMPOUND STATEMENTS

CS 101: Computer Programming and Utilization

Digital Fundamentals

Advanced Computer Architecture-CS501

Level ISA3: Information Representation

Digital Fundamentals

Logic Circuits I ECE 1411 Thursday 4:45pm-7:20pm. Nathan Pihlstrom.

World Inside a Computer is Binary

CO Computer Architecture and Programming Languages CAPL. Lecture 9

2 Number Systems 2.1. Foundations of Computer Science Cengage Learning

CHAPTER 2 Number Systems

Chapter 1 Review of Number Systems

CS & IT Conversions. Magnitude 10,000 1,

CS2214 COMPUTER ARCHITECTURE & ORGANIZATION SPRING 2014

Binary Representations and Arithmetic

CS101 Lecture 04: Binary Arithmetic

MACHINE LEVEL REPRESENTATION OF DATA

Number Systems CHAPTER Positional Number Systems

Number Systems. Readings: , Problem: Implement simple pocket calculator Need: Display, adders & subtractors, inputs

Electronic Data and Instructions

Signed umbers. Sign/Magnitude otation

1DT157 Digitalteknik och datorarkitekt. Digital technology and computer architecture, 5p

CHAPTER V NUMBER SYSTEMS AND ARITHMETIC

Digital Electronics A Practical Approach with VHDL William Kleitz Ninth Edition

Basic Definition INTEGER DATA. Unsigned Binary and Binary-Coded Decimal. BCD: Binary-Coded Decimal

A Level Computing. Contents. For the Exam:

Korea University of Technology and Education

Numeral Systems. -Numeral System -Positional systems -Decimal -Binary -Octal. Subjects:

BINARY SYSTEM. Binary system is used in digital systems because it is:

Groups of two-state devices are used to represent data in a computer. In general, we say the states are either: high/low, on/off, 1/0,...

Part 2,Number Systems Questions

UNIT 7A Data Representation: Numbers and Text. Digital Data

Moodle WILLINGDON COLLEGE SANGLI. ELECTRONICS (B. Sc.-I) Introduction to Number System

Lecture (02) Operations on numbering systems

Chapter 2. Positional number systems. 2.1 Signed number representations Signed magnitude

IT 1204 Section 2.0. Data Representation and Arithmetic. 2009, University of Colombo School of Computing 1

Module 2: Computer Arithmetic

ECE 2020B Fundamentals of Digital Design Spring problems, 6 pages Exam Two 26 February 2014

Lecture 2: Number Systems

FLOATING POINT NUMBERS

NAME: 1a. (10 pts.) Describe the characteristics of numbers for which this floating-point data type is well-suited. Give an example.

QUIZ: Generations of computer technology. Hardware:

Number Systems. Decimal numbers. Binary numbers. Chapter 1 <1> 8's column. 1000's column. 2's column. 4's column

The type of all data used in a C++ program must be specified

ECE 2030B 1:00pm Computer Engineering Spring problems, 5 pages Exam Two 10 March 2010

Objectives. Connecting with Computer Science 2

Homework 1 graded and returned in class today. Solutions posted online. Request regrades by next class period. Question 10 treated as extra credit

Lab Using the Windows Calculator with Network Addresses

Number Systems and Binary Arithmetic. Quantitative Analysis II Professor Bob Orr

COMPUTER ARITHMETIC (Part 1)

Slide Set 1. for ENEL 339 Fall 2014 Lecture Section 02. Steve Norman, PhD, PEng

Introduction to Computer Science. Homework 1

Information Science 1

Chapter 3: Number Systems and Codes. Textbook: Petruzella, Frank D., Programmable Logic Controllers. McGraw Hill Companies Inc.

4/8/17. Admin. Assignment 5 BINARY. David Kauchak CS 52 Spring 2017

Lecture (01) Digital Systems and Binary Numbers By: Dr. Ahmed ElShafee

Integers and Floating Point

Chapter 2: Number Systems

Hexadecimal Numbers. Journal: If you were to extend our numbering system to more digits, what digits would you use? Why those?

ECOM 2325 Computer Organization and Assembly Language. Instructor: Ruba A.Salamah INTRODUCTION

Floating-point Arithmetic. where you sum up the integer to the left of the decimal point and the fraction to the right.

Fundamentals of Programming Session 2

Digital Logic. The Binary System is a way of writing numbers using only the digits 0 and 1. This is the method used by the (digital) computer.

MYcsvtu Notes DATA REPRESENTATION. Data Types. Complements. Fixed Point Representations. Floating Point Representations. Other Binary Codes

UNIT1: COMPUTERNUMBER SYSTEM

Digital Systems and Binary Numbers

Chapter 1 Emad Felemban

Excerpt from: Stephen H. Unger, The Essence of Logic Circuits, Second Ed., Wiley, 1997

ECE 2020B Fundamentals of Digital Design Spring problems, 6 pages Exam Two Solutions 26 February 2014

Module 1: Information Representation I -- Number Systems

Digital Fundamentals

data within a computer system are stored in one of 2 physical states (hence the use of binary digits)

Number Systems. Binary Numbers. Appendix. Decimal notation represents numbers as powers of 10, for example

Transcription:

CS/EE2 INTRODUCTION TO COMPUTER ENGINEERING SPRING 23 DUE : February 22, 23 HOMEWORK I READ : Related portions of the following chapters : È Chapter È Chapter 2 È Appendix E ASSIGNMENT : There are eight questions from the textbook Solve all homework and exam problems as shown in class and sample solutions ) Solve Problem.8. 2) Solve Problem 2.6. 3) Solve Problem 2. (b). 4) Solve Problem 2.2. 5) Solve Problem 2.4 (a) and (e). Assume that the numbers are 2 s Complement numbers. Indicate if there is an overflow. 6) Solve Problem 2.8 (b). 7) Solve Problem 2.2 (c). 8) Solve Problem 2.46 (e). Polytechnic Institute of NYU Page of 8 Handout No : 2 February, 23

RELEVANT QUESTIONS AND ANSWERS Q) Hex digits are used to represent two numbers that are 6-bit 2 s complement numbers : 4AF8 - B5E = ( ) Perform the subtraction operation, by converting it to a 6-bit addition operation. Show the result in decimal. A) First, we convert the digits to bit strings : by using 6 bits 4 A F 8 by using 6 bits B 5 E In order to convert the subtraction to an addition, we need to take the 2 s complement of the second number : 2 ( ) = ( ) We calculate the corresponding decimal number : 5 4 3 2 9 8 7 6 5 4 3 2 By numbering the bit positions from right to left, starting at, we convert the binary number to a decimal number : ==> 2 2 3 2 4 2 7 2 8 2 9 2 2 2 3 = 2 8 6 28 256 52 24 248 892 = (286) Observation : we added a negative number and a positive number, therefore, there cannot be any overflow. Q2) Perform the following operation in 2 s complement arithmetic : F6 49 = The numbers are shown in the Hexadecimal notation. Thus, first convert the numbers to binary, and then add them. Make observations on the addition. A2) Replace each hexadecimal digit with four bits to convert them to 2 s Complement numbers : Polytechnic Institute of NYU Page 2 of 8 CS/EE2 Handout No : 2 February, 23

F 6 F 6 4 9 4 9 (3 F) Hex 3 F There is no overflow, since the two numbers added have different sign bits : one is negative and the other is positive. Thus, the result cannot exceed the limits for 8-bit 2 s complement numbers : (-28) and (27). The bit is the carry out from the leftmost bit position and it is. Q3) Without using a calculator, perform the following addition in binary as shown in class : 2 s complement numbers Make observations on the addition. Finally, convert the result to decimal. A3) We are given the following addition : 2 s complement numbers Since it is the 2 s complement system and the second number is shorter than the first, we sign extend the second number so both numbers have eight bits. The sign bit of the second number is (it is negative), so we have to catenate s to the left of it : Now we have the following addition : Observation : we know that there cannot be any overflow since we added a positive number (the first number) and a negative number (the second number). We convert the result to decimal directly since the result is positive : 7 6 5 4 3 2 2 6 2 3 2 2 64 8 4 (76) the result Polytechnic Institute of NYU Page 3 of 8 CS/EE2 Handout No : 2 February, 23

Q4) Consider the following 8-bit addition on two 2 s Complement Binary numbers where the first number is shown in Hex coding : (A 5) Hex Hex coded Without using a calculator, perform the 8-bit 2 s Complement Binary addition as shown in class. Make observations on the overflow. Then, convert the result to a decimal number as shown in class. Note again that both numbers above are 2 s Complement Binary numbers and the first number is shown in Hex-coding. A4) Since the first number is Hex coded, first we replace its Hex coded digits with bits. Then, we perform the addition in the 2 s Complement Binary system : (A 5) Hex (A 5) Hex = A 5 c in We added two negative numbers and the result is negative. Thefore, there is no overflow. That is, the result is correct! We can convert the result to decimal. Since the result is negative, we have to make it positive first : 2 = 7 6 5 4 3 2 2 6 2 5 2 3 2 2 2 = 64 32 8 4 = (9) =>(-9) Q5) Consider the following subtraction on 2 s Complement numbers represented in Hex coding : 8 A 8 Without using a calculator, perform the 8-bit 2 s Complement Binary subtraction, by converting it to an 8-bit addition as shown in class. Make observations on the overflow. Then, convert the result to a decimal number as shown in class. Note again that both Hex-coded numbers above are 2 s Complement Binary numbers and so you will perform the subtraction via an addition. A5) Since the numbers are Hex coded, first we replace the Hex coded digits with bits. Then, before we convert the subtraction to an addition in the 2 s Complement Binary system, we perform a sign extension on the second number since it is shorter : Polytechnic Institute of NYU Page 4 of 8 CS/EE2 Handout No : 2 February, 23

8 A 8 A 8 8 c in We added two numbers with opposite signs. There cannot be an overflow. That is, the result is correct! We can convert the result to decimal. Since the result is negative, we have to make it positive first : 2 = 7 6 5 4 3 2 2 6 2 5 2 3 2 2 2 = 64 32 8 4 2 = () =>(-) Q6) Determine the base (radix) of the numbers used in the following addition : 3 6 = 2 A6) There are several ways to solve the problem. One that uses the general conversion formula is as follows : È First we have to see if 6 in the unknown radix is equal to 6 in decimal. By using the general conversion formula we see that : (6) r = (6) r = 6 * r = 6 * = (6) È Then, we do the addition by using the general conversion formula to obtain the unknown radix r : 3 6 2 ( 3) r (6) r = (2 ) r => ( * r ) (3 * r ) 6 = (2 * r ) ( * r ) => r 3 6 = 2r => r 9 = 2r => r = 8 Q7) Without using a calculator, perform the following 8-bit 2 s Complement Binary subtraction, by converting it to an 8-bit addition as shown in class : Polytechnic Institute of NYU Page 5 of 8 CS/EE2 Handout No : 2 February, 23

Make observations on the overflow. Then, convert the result to a decimal number and also code the result in Hexadecimal as shown in class. Note again that both numbers above are 2 s Complement Binary numbers and so you will perform the subtraction via an addition. A7) Before we convert the subtraction to an addition in the 2 s Complement Binary system, we perform a sign extension on the second number since it is shorter and both numbers are 2 s Complement numbers : c in We added two numbers with opposite signs. There cannot be an overflow. That is, the result is correct! We can convert the result to decimal. Since the result is negative, we have to make it positive first : 2 = 2 6 2 5 2 2 2 = 64 32 4 = () 7 6 5 4 3 2 =>(-) The result of the addition in terms of Hex digits : 9 B (9B) Hex Q8) Perform the following subtraction operation on the two 8-bit 2 s complement binary numbers below, by converting it to an 8-bit addition operation. Also, determine the missing bits and show the result in decimal : a b s - ( ) A8) (b) We need to take the 2 s complement of (b) to convert the subtraction to an addition first : 2 2 ( b ) = ( ) = = (-b) Polytechnic Institute of NYU Page 6 of 8 CS/EE2 Handout No : 2 February, 23

(-b) The sum is a negative number. We cannot convert it to decimal directly. We will convert the negative of the sum to decimal : 2 (-sum) = () = = 2 2 2 3 2 5 = 2832 = (43). The sum is (-43) Number b is also a negative number. We will convert its negative to decimal first : (-b) = => 2 2 2 2 3 2 4 = 4 8 6 = (29) => b = (-29) 7 6 5 4 3 2 Note that we added a negative number (a) and a positive number (-b), therefore, there cannot be any overflow. Q9) Consider the following addition on two 2 s Complement Binary numbers : Without using a calculator, perform the addition as shown in class. Make observations on the overflow. Then, convert the result to a decimal number as shown in class. Finally, show the result in Hexadecimal coding as done in class. Q9) We perform the addition as follows : We see that the second number has less number of bits. We perform a sign extension on the second number since we are adding 2 s Complement numbers We added two negative numbers and the result is negative. Thefore, there is no overflow. That is, the result is correct! We can convert the result to decimal. Since the result is negative, we have to make it positive first : Polytechnic Institute of NYU Page 7 of 8 CS/EE2 Handout No : 2 February, 23

2 = 2 5 2 3 2 2 2 = 32 8 4 2 = (46) 7 6 5 4 3 2 =>(-46) D 2 =>(D2) Hex Q) Consider the following subtraction on two 2 s Complement Binary numbers : - Without using a calculator, perform the 2 s Complement Binary subtraction, by converting it to an addition as shown in class. Make observations on the overflow. Then, convert the result to a decimal number as shown in class. Finally, show the result in Hexadecimal coding as done in class. A) We perform the addition as follows : - In order to convert the subtraction to an addition, we complement the second number and add c in We added two numbers with opposite signs Thefore, there cannot be an overflow That is, the result is correct! 7 6 5 4 3 2 2 5 2 2 = 32 2 = (35) 2 3 => (23) Hex Polytechnic Institute of NYU Page 8 of 8 CS/EE2 Handout No : 2 February, 23