CMPSCI 145 MIDTERM #1 Solution Key. SPRING 2017 March 3, 2017 Professor William T. Verts

Similar documents
Chapter 03: Computer Arithmetic. Lesson 09: Arithmetic using floating point numbers

CHW 261: Logic Design

CMPSCI 145 MIDTERM #2 SOLUTION KEY SPRING 2015 April 3, 2015 Professor William T. Verts

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

Number Systems. Both numbers are positive

Chapter 3: Arithmetic for Computers

Floating Point Arithmetic

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

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

CMPSCI 145 MIDTERM #2 SPRING 2017 April 7, 2017 Professor William T. Verts NAME PROBLEM SCORE POINTS GRAND TOTAL 100

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

Floating Point. The World is Not Just Integers. Programming languages support numbers with fraction

Organisasi Sistem Komputer

Digital Fundamentals

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

CS 101: Computer Programming and Utilization

Module 2: Computer Arithmetic

Floating-Point Data Representation and Manipulation 198:231 Introduction to Computer Organization Lecture 3

Divide: Paper & Pencil

Signed umbers. Sign/Magnitude otation

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

Chapter 5 : Computer Arithmetic

Introduction to Computers and Programming. Numeric Values

Number Systems and Computer Arithmetic

Logic, Words, and Integers

Chapter 2 Bits, Data Types, and Operations

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

CMPSCI 145 MIDTERM #2 Solution Key SPRING 2018 April 13, 2018 Professor William T. Verts

Chapter 2 Bits, Data Types, and Operations

ECE 2030D Computer Engineering Spring problems, 5 pages Exam Two 8 March 2012

Experimental Methods I

CHAPTER 1 Numerical Representation

Floating Point Numbers

Floating Point Numbers

CMPSCI 145 MIDTERM #2 SOLUTION KEY SPRING 2016 March 30, 2016 Professor William T. Verts

1. NUMBER SYSTEMS USED IN COMPUTING: THE BINARY NUMBER SYSTEM

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

Chapter 2 Bits, Data Types, and Operations

Signed Multiplication Multiply the positives Negate result if signs of operand are different

Digital Fundamentals

Computer (Literacy) Skills. Number representations and memory. Lubomír Bulej KDSS MFF UK

ECE331: Hardware Organization and Design

COMPUTER ARCHITECTURE AND ORGANIZATION. Operation Add Magnitudes Subtract Magnitudes (+A) + ( B) + (A B) (B A) + (A B)

The ALU consists of combinational logic. Processes all data in the CPU. ALL von Neuman machines have an ALU loop.

Number Systems CHAPTER Positional Number Systems

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

Bits, Words, and Integers

COMP2611: Computer Organization. Data Representation

ECE232: Hardware Organization and Design

CO212 Lecture 10: Arithmetic & Logical Unit

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

CS 265. Computer Architecture. Wei Lu, Ph.D., P.Eng.

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

Advanced Computer Architecture-CS501

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

Read this before starting!

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

Chapter 4. Operations on Data

unused unused unused unused unused unused

Chapter 2. Data Representation in Computer Systems

CHAPTER 5: Representing Numerical Data

ECE 30 Introduction to Computer Engineering

Chapter 2 Bits, Data Types, and Operations

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

COSC 243. Data Representation 3. Lecture 3 - Data Representation 3 1. COSC 243 (Computer Architecture)

Programming Using C Homework 4

Read this before starting!

At the ith stage: Input: ci is the carry-in Output: si is the sum ci+1 carry-out to (i+1)st state

Computer Architecture and IC Design Lab. Chapter 3 Part 2 Arithmetic for Computers Floating Point

MACHINE LEVEL REPRESENTATION OF DATA

COMP Overview of Tutorial #2

Numbers and Computers. Debdeep Mukhopadhyay Assistant Professor Dept of Computer Sc and Engg IIT Madras

Binary Addition & Subtraction. Unsigned and Sign & Magnitude numbers

C NUMERIC FORMATS. Overview. IEEE Single-Precision Floating-point Data Format. Figure C-0. Table C-0. Listing C-0.

CHAPTER V NUMBER SYSTEMS AND ARITHMETIC

Integers. N = sum (b i * 2 i ) where b i = 0 or 1. This is called unsigned binary representation. i = 31. i = 0

IEEE Standard for Floating-Point Arithmetic: 754

Read this before starting!

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

4 Operations On Data 4.1. Foundations of Computer Science Cengage Learning

Introduction to Computer Science-103. Midterm

Floating Point Numbers

CS101 Lecture 04: Binary Arithmetic

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

9/3/2015. Data Representation II. 2.4 Signed Integer Representation. 2.4 Signed Integer Representation

Chapter 4: Data Representations

M1 Computers and Data

Floating Point Numbers. Lecture 9 CAP

Chapter 4: The Building Blocks: Binary Numbers, Boolean Logic, and Gates. Invitation to Computer Science, C++ Version, Third Edition

3.1 DATA REPRESENTATION (PART C)

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

Recap from Last Time. CSE 2021: Computer Organization. It s All about Numbers! 5/12/2011. Text Pictures Video clips Audio

CS 261 Fall Floating-Point Numbers. Mike Lam, Professor.

CSC201, SECTION 002, Fall 2000: Homework Assignment #2

World Inside a Computer is Binary

15213 Recitation 2: Floating Point

Fundamentals of Programming Session 2

Computer Arithmetic Ch 8

Computer Arithmetic Ch 8

D I G I T A L C I R C U I T S E E

Transcription:

CMPSCI 145 MIDTERM #1 Solution Key NAME SPRING 2017 March 3, 2017 PROBLEM SCORE POINTS 1 10 2 10 3 15 4 15 5 20 6 12 7 8 8 10 TOTAL 100

<1> 10 Points Examine the following diagram of two systems, one involving gears and the other involving resistors. Resistor R1 is 2000 Ohms, and resistor R2 is 1000 Ohms. Gear G1 has 50 teeth. A. (5 points) What is the output voltage of the circuit if the input voltage was 24 volts? The total resistance is 3000 Ohms, and the output voltage is measure across the 1000 Ohm resistor, so the output voltage is ⅓ of the input. If the input is 24 volts, the output is then 8 volts. B. (5 points) How many teeth must gear G2 have so that the division ratio of the gears matches the division ratio of the resistors? (Ignoring differences in sign.) G2 must spin at ⅓ the rate of G1, so it must have 3 times the number of teeth as G1. Thus, G2 must have 150 teeth. Page 1

<2> 10 Points The image to the right shows a standard 12-hour clock, where the 12:00 position represents zero. Compute the following sums, and tell me if there is an unsigned overflow, a signed overflow, both or neither: 5 points: + = 3+4=7, which does not give an unsigned overflow, but in signed clock 3+4=-5, which is a signed overflow. 5 points: + = 2+2=4, which is neither a signed nor an unsigned overflow. Scoring: 5 points each problem, 3 for the answer (-1 for not expressing the answer as a clock) and 2 for the correct determination of overflow. Page 2

<3> 15 Points (1 point each box) Solve each sum below, and then tell me, yes or no, if it exhibits unsigned overflow or signed overflow. For problems that use four-digit decimal arithmetic (base 10), the left-most digit is the sign digit, and you are to write down only the right-most four digits of the sum even if a carry to a fifth digit is generated. For problems that use eight-bit binary arithmetic (base 2), the left-most bit is the sign bit, and you are to write down only the right-most eight bits of the sum, even if a carry to a ninth bit is generated. (-½ per problem for writing extra digits.) Problem Decimal: 2409 + 2427 Decimal: 8723 + 3146 Decimal: 7791 + 6918 Binary: 10010111 + 11001011 Binary: 11010011 + 01011010 Sum (in four decimal digits or eight binary bits) Unsigned Overflow? Signed Overflow? 4836 no no 1869 yes no 4709 yes yes 01100010 yes yes 00101101 yes no <4> 15 Points (1 point each box) Show the decimal (base 10) value of the eight-bit binary numbers interpreted in each of the following ways. One problem has been done for you. For signed interpretations, the left-most bit is the sign bit. The Number 01101110 11111111 10110111 Unsigned Binary Sign & Magnitude Signed Binary One s Complement Signed Binary Two s Complement Signed Binary Unsigned Fixed-Point (6 bits whole number, 2 bits fraction) 110 255 183 +110-127 -55 +110-0 -72 +110-1 -73 27.5 63.75 45.75 Note for scoring: the signed values all have + or as prefixes. recommended, but not required. The + prefix is Page 3

<5> 20 Points Convert the decimal number -37.5625 into True Binary (5 points), Binary Scientific Notation (5 points), and Single-Precision Floating Point (10 points). Show your work for partial credit. True Binary: -100101.1001 (sign 1 point, integer 2 points, fraction 2 points) Binary Scientific: -1.001011001 2 5 (sign 1 point, mantissa 2 points, exponent 2 points) (1 point) The number is negative, so sign bit = 1. (3 points) The true exponent is 5, so after adding the bias of 127 the biased exponent is 132, or 10000100 in binary, which is stored in the biased exponent field. The significant digits are 1.001011001, so after suppressing the leading 1 the fraction that is actually stored is 001011001 (4 points, -1 for keeping the leading 1-bit) and the remaining bits are padded with 0 bits (2 points). Note for scoring: if the True Binary is wrong but all subsequent derivations are consistent with that wrong answer, there should be no additional penalty. Similarly, if the True Binary is right and the Binary Scientific is wrong, there will be no additional penalty if the Single Precision is correctly derived from the incorrect Binary Scientific. <6> 12 Points Which of the following devices are analog and which are digital? (2 points each) A. A slide rule Analog B. Magnetic core memory Digital C. A gear Analog D. A NAND-gate Digital E. A hydraulic press Analog F. A resistor-capacitor circuit Analog Page 4

<7> 8 Points Trace the following circuit and show the outputs for all given inputs. (½ point each.) A1 A0 C3 C2 C1 C0 0 0 0 0 0 0 0 1 0 0 0 1 1 0 0 1 0 0 1 1 1 0 0 1 Note that this circuit squares its input. <8> 10 Points SHORT ANSWER How is dividing a decimal number by 10 similar to dividing a binary number by 2? (For example, 5247 10 = 524.7 and 110101 2 = 11010.1) Consider the concept of shifting in your answer. Use the back of this page for your answer. Dividing a decimal number by 10 shifts the number to the right, and the least significant integer digit goes to the right of the decimal point. Similarly, dividing a binary number by 2 also shifts the number one bit to the right, and the least significant bit goes to the right of the decimal point (actually, binary point). To generalize, dividing any number in any base by an integer N is the same as rightshifting the number in base N, and the base N remainder goes to the right of the decimal point. This allows conversion of any number in any base to any other base. (For example, dividing a decimal number by 2 using base 10 arithmetic effectively shifts the number right by one bit in binary, allowing for easy conversion of decimal to binary.) Scoring: Assign the full 10 points if the answer is a reasonably complete discussion of shifting AND talks about using the method for base conversion (that is, they get it ), assign 5 points for any intermediate answer, and 0 points if the answer is completely bogus. Page 5