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

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

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

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

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

Floating Point Arithmetic

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

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

Floating Point Numbers. Lecture 9 CAP

COMP2611: Computer Organization. Data Representation

Numeric Encodings Prof. James L. Frankel Harvard University

3 Data Storage 3.1. Foundations of Computer Science Cengage Learning

Floating Point Numbers

Floating Point Numbers

Number Systems. Both numbers are positive

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

Chapter 3: Arithmetic for Computers

ECE232: Hardware Organization and Design

CS 61C: Great Ideas in Computer Architecture Performance and Floating-Point Arithmetic

CS 61C: Great Ideas in Computer Architecture Performance and Floating Point Arithmetic

Set Theory in Computer Science. Binary Numbers. Base 10 Number. What is a Number? = Binary Number Example

Floating point. Today! IEEE Floating Point Standard! Rounding! Floating Point Operations! Mathematical properties. Next time. !

CSCI 402: Computer Architectures. Arithmetic for Computers (3) Fengguang Song Department of Computer & Information Science IUPUI.

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

Floating Point (with contributions from Dr. Bin Ren, William & Mary Computer Science)

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

Outline. What is Performance? Restating Performance Equation Time = Seconds. CPU Performance Factors

CS 61C: Great Ideas in Computer Architecture Performance and Floating-Point Arithmetic

15213 Recitation 2: Floating Point

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

ecture 25 Floating Point Friedland and Weaver Computer Science 61C Spring 2017 March 17th, 2017

EE 109 Unit 19. IEEE 754 Floating Point Representation Floating Point Arithmetic

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

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

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

Chapter 2 Float Point Arithmetic. Real Numbers in Decimal Notation. Real Numbers in Decimal Notation

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

Foundations of Computer Systems

CHW 261: Logic Design

Chapter 3 Arithmetic for Computers (Part 2)

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

Numerical computing. How computers store real numbers and the problems that result

Floating-point representation

Floating Point. CSE 351 Autumn Instructor: Justin Hsia

Floating point. Today. IEEE Floating Point Standard Rounding Floating Point Operations Mathematical properties Next time.

MATH 353 Engineering mathematics III

Data Representation Floating Point

CO212 Lecture 10: Arithmetic & Logical Unit

Real Numbers finite subset real numbers floating point numbers Scientific Notation fixed point numbers

Floating Point Arithmetic

Data Representation Floating Point

unused unused unused unused unused unused

CS 61C: Great Ideas in Computer Architecture Floating Point Arithmetic

CS101 Lecture 04: Binary Arithmetic

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

M1 Computers and Data

Read this before starting!

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

Finite arithmetic and error analysis

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

INTEGER REPRESENTATIONS

FLOATING POINT NUMBERS

CMPSCI 201 Fall 2005 Midterm #2 Solution

Floating Point Puzzles. Lecture 3B Floating Point. IEEE Floating Point. Fractional Binary Numbers. Topics. IEEE Standard 754

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

Natural Numbers and Integers. Big Ideas in Numerical Methods. Overflow. Real Numbers 29/07/2011. Taking some ideas from NM course a little further

CSAP Achievement Levels Mathematics Grade 7 March, 2006

2 Computation with Floating-Point Numbers

Integers and Floating Point

Bindel, Fall 2016 Matrix Computations (CS 6210) Notes for

Floating Point Considerations

Computer Systems C S Cynthia Lee

Binary Addition & Subtraction. Unsigned and Sign & Magnitude numbers

Floating-Point Arithmetic

Chapter 4: Data Representations

2 Computation with Floating-Point Numbers

Floating Point. CSE 351 Autumn Instructor: Justin Hsia

IEEE Standard 754 Floating Point Numbers

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

CS61C : Machine Structures

Course Schedule. CS 221 Computer Architecture. Week 3: Plan. I. Hexadecimals and Character Representations. Hexadecimal Representation

Digital Fundamentals

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

CS321 Introduction To Numerical Methods

Floating Point. CSE 351 Autumn Instructor: Justin Hsia

Computer Architecture Chapter 3. Fall 2005 Department of Computer Science Kent State University

8/30/2016. In Binary, We Have A Binary Point. ECE 120: Introduction to Computing. Fixed-Point Representations Support Fractions

Read this before starting!

Floating Point Puzzles The course that gives CMU its Zip! Floating Point Jan 22, IEEE Floating Point. Fractional Binary Numbers.

Floating-Point Arithmetic

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

CS367 Test 1 Review Guide

Floating-point representations

Floating-point representations

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

Scientific Computing. Error Analysis

Floating Point Arithmetic

CS61C : Machine Structures

Systems I. Floating Point. Topics IEEE Floating Point Standard Rounding Floating Point Operations Mathematical properties

Chapter 10 - Computer Arithmetic

Module 2: Computer Arithmetic

Transcription:

CMPSCI 145 MIDTERM #2 SOLUTION KEY SPRING 2015 April 3, 2015 Page 1

<1> 15 Points Answer 15 of the following problems (1 point each). Answer more than 15 for extra credit. Incorrect or blank answers will be ignored. 185-57 -71 86 0 1 2 0 (#1 inside #2) <4,1,0> <10,7> YES Triangles O(N) O(log 2 (N)) O(N 2 ) O(N log 2 (N)) [9.4, 9.6].GIF.JPG,.PNG.SVG What is the decimal value of the 8-bit unsigned binary number 10111001? What is the decimal value of the 8-bit sign and magnitude binary number 10111001? What is the decimal value of the 8-bit two s complement signed binary number 10111001? What is the decimal value of the 2-digit XS3 binary number 10111001? radius 2. How many points of intersection are there? radius 7. How many points of intersection are there? radius 9. How many points of intersection are there? Circle #1 is at <0,0> with radius 3. Circle #2 is at <5,5> with radius 30. How many points of intersection are there? A 3D ray has equations x(t)=6t+1, y(t)=-8t+5, z(t)=4t-2. What are the coordinates of the point at t=½? What point in 2D is halfway between <6,4> and <14,10>? Yes or No: Can I mathematically draw a line (i.e., compute intermediate points) between two points in 6 dimensions? Besides spheres, what geometric object is most suitable for raytracing? O(N log 2 (N)), O(N 2 ), O(N 3 ), etc.) of a linear search? O(N log 2 (N)), O(N 2 ), O(N 3 ), etc.) of a binary search? O(N log 2 (N)), O(N 2 ), O(N 3 ), etc.) of an insertion sort? O(N log 2 (N)), O(N 2 ), O(N 3 ), etc.) of a heap sort? Using interval arithmetic, what is the sum of the two intervals [3.1, 3.2] and [6.3, 6.4]? supports simple animations? supports lossy compression for photographs? supports line-art that can be scaled to any size? Page 2

<2> 25 Points We are going to invent a new floating-point format, called eighth-precision which is exactly four bits in length. There is no sign bit (all numbers are positive), only two bits for the biased exponent, and two bits for the mantissa, but otherwise all rules are the same as single, double, half, and quarter precision. All 16 patterns are shown below, with the exponent field shaded a light gray. A. (3 Points) What is the value of the bias for this format? 2 2-1 -1 = 1 B. (15 Points) Label each pattern to tell me if it is Infinity, NaN, Normalized, Denormal, or Zero (only one answer per pattern). Three points extra credit for correctly telling me which NaN patterns are signaling NaN or quiet NaN. C. (7 Points) For each Normalized pattern, write down its binary scientific notation value, its true binary value, and its decimal value. One pattern is shown with all correct answers. Three points extra credit for correctly solving the Denormal patterns as well. Page 3

<3> 20 Points In the list: April Bob Carol Dan Emma Fred George Hal Iris John Karen Larry Mary Nora Opal A. (5 Points) Which is the first name examined in a linear search? April B. (5 Points) Which is the first name examined in a binary search? Hal C. (5 Points) How many names will be examined when looking for Karen using binary search? (Hal, Larry, John, then Karen) 4 D. (5 Points) In a self-organizing list using the move-to-front approach, what is the order of the names in the list after we search for Fred? Fred April Bob Carol Dan Emma George Hal Iris John Karen Larry Mary Nora Opal <4> 10 Points The image below shows the tree representation for an arithmetic expression (F and X are algebraic variables, #0 and #1 are just the numeric constants 0 and 1, the * symbol means multiplication, and / means division): 1. (5 points) Write out the complete algebraic equation for the current tree representation as shown, including parentheses where necessary. (F + 0) * (X / (X * 1)) 2. (5 points) Figure out how to optimize the tree to most efficiently compute the exact same value as what is shown here, and then draw that resulting tree. (The tree might reduce down to a single node.) F + 0 goes to F, X * 1 goes to X, X / X goes to 1, F * 1 goes to F (final result). Page 4

<5> 15 Points In the following Lagrange interpolation for a parabola, fill in the blanks with numbers so that the curve passes through P 0 when t = -5, through P 1 when t = 0, and through P 2 when t = 5. <6> 15 Points Short Answer If someone asked you what a particular binary number meant, how would you answer them in light of what we have learned in this class? Is it possible to tell them what the binary number actually is, what it can be, or what it cannot be? Justify your answer with examples. It depends entirely on the context in which the number was generated. There is nothing inherent in any binary number which tells us which interpretation to use. We can discount some interpretations, such as 1100 cannot be BCD for example. If we do not know the context, we cannot tell what the number is, but we can say what it can be (list of possibilities for which the number is not illegal), and we can definitely say what the number cannot be. Page 5