CMPSCI 145 MIDTERM #2 SOLUTION KEY SPRING 2016 March 30, 2016 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 2015 April 3, 2015 Professor William T. Verts

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

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

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

Number Systems. Both numbers are positive

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

ECE232: Hardware Organization and Design

CS101 Lecture 04: Binary Arithmetic

COMP2611: Computer Organization. Data Representation

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

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

Floating Point Arithmetic

Floating Point Numbers. Lecture 9 CAP

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

Integers and Floating Point

Numeric Encodings Prof. James L. Frankel Harvard University

Foundations of Computer Systems

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

3 Data Storage 3.1. Foundations of Computer Science Cengage Learning

Lecture 10: Floating Point, Digital Design

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

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

Data Representation 1

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

15213 Recitation 2: Floating Point

Floating Point Numbers

Floating Point Numbers

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

Chapter 3: Arithmetic for Computers

Finite arithmetic and error analysis

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

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

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

Operations On Data CHAPTER 4. (Solutions to Odd-Numbered Problems) Review Questions

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

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

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

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

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

Chapter 2 Bits, Data Types, and Operations

CHW 261: Logic Design

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

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

Floating Point. CSE 351 Autumn Instructor: Justin Hsia

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

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

Chapter 2 Bits, Data Types, and Operations

MACHINE LEVEL REPRESENTATION OF DATA

CMPSCI 201 Fall 2005 Midterm #2 Solution

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

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

Math 340 Fall 2014, Victor Matveev. Binary system, round-off errors, loss of significance, and double precision accuracy.

Data Representation Floating Point

Floating Point. CSE 351 Autumn Instructor: Justin Hsia

Floating Point Arithmetic

Read this before starting!

Introduction to Computer Systems Recitation 2 May 29, Marjorie Carlson Aditya Gupta Shailin Desai

CO212 Lecture 10: Arithmetic & Logical Unit

unused unused unused unused unused unused

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

Data Representation Floating Point

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

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

Chapter 2 Bits, Data Types, and Operations

CHAPTER V NUMBER SYSTEMS AND ARITHMETIC

Computer Organisation CS303

Floating Point. CSE 351 Autumn Instructor: Justin Hsia

Floating Point Numbers

Read this before starting!

Read this before starting!

Computer Arithmetic Floating Point

Digital Fundamentals

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

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

ECE331: Hardware Organization and Design

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

Chapter 3 Arithmetic for Computers (Part 2)

Data Representation and Networking

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

CS61c Midterm Review (fa06) Number representation and Floating points From your friendly reader

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

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

Chapter 2 Bits, Data Types, and Operations

3.5 Floating Point: Overview

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

Floating-Point Arithmetic

Chapter 2. Data Representation in Computer Systems

Bits, Words, and Integers

Representing and Manipulating Floating Points. Jo, Heeseung

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

Signed umbers. Sign/Magnitude otation

Floating Point January 24, 2008

Representing and Manipulating Floating Points

Floating Point Arithmetic

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

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

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

Chapter 2 Data Representations

Giving credit where credit is due

Transcription:

CMPSCI 145 MIDTERM #2 SOLUTION KEY SPRING 2016 March 30, 2016 Items in red are students expected answers or instructions on scoring to the grader. Items in light blue are my annotations or explanations, and are not required as part of students answers. 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. 149-21 -106-107 95 62 101010011 100000100 -or- 104 Denormal NaN -or- NotANumber Infinity Kiss at one point Overlap Lossy Lossless Dithering 11025 1 2= 22050 False (1 part in 65536) 5512.5 Steganography What is the decimal value of the 8-bit unsigned binary number 10010101? What is the decimal value of the 8-bit sign and magnitude binary number 10010101? What is the decimal value of the 8-bit one s complement signed binary number 10010101? What is the decimal value of the 8-bit two s complement signed binary number 10010101? What is the decimal value of the 2-digit BCD binary number 10010101? What is the decimal value of the 2-digit XS3 binary number 10010101? What is the binary sum of 10010101 and 10111110? (You may need more than 8 bits.) What is the BCD binary sum of 10010101 and 00001001? (You may need more than 8 bits.) In floating-point, what are numbers called where the biased exponent is equal to zero and the mantissa is non-zero? In floating-point, what are numbers called where the biased exponent is all 1-bits and the mantissa is non-zero? In floating-point, what is the number called where the biased exponent is all 1-bits and the mantissa is zero? Two spheres, each of radius 100 units, have centers 200 units apart. Do they overlap, kiss at one point, or miss each other? Two spheres, each of radius 100 units, have centers 150 units apart. Do they overlap, kiss at one point, or miss each other? What kind of compression is used when I save a 24-bit.BMP file in the.jpg format? What kind of compression is used when I save a 256-color (or less).bmp file in the.gif format? What is it called when I reduce the colors in an image and distribute the error (difference in color) to neighboring pixels? A sound file is recorded at 2 byte/sample, 1 channel, and 11025 samples/second/channel. How many bytes/second are played? Using 1 byte/sample, a sound can be measured to one part in 256. True/False: 2 bytes/sample is good to one part in 512? What is the maximum frequency that can be represented in a sound recorded at 11025 samples/second/channel? What is it called when I hide a data bit in the low-order bit of either a sound sample or the blue channel of a graphics pixel? Page 2

<2> 25 Points We are going to invent a new floating-point format, called weird-precision which is exactly ten bits in length. There is a sign bit, four bits for the biased exponent, and five bits for the mantissa, and all rules are the same as single, double, half, and quarter precision. A. (3 Points) What is the value of the bias for this format? 2 4-1 -1 = 2 3-1 = 8-1 = 7 Accept only 7 for full credit, 1 point for 2 4-1 -1, 2 points for 2 3-1 or 8-1. B. (15 Points) Fill in all the boxes below with 0 and 1 to form the indicated values: Quiet NaN X: accept 0, 1, X. Positive Infinity Largest Normalized Positive Value Smallest Normalized Positive Value Three points per answer. Score as 2 for up to two bits in error; score as 1 for three to five bits in error, score as 0 for more than five bits in error. C. (6 Points) What are the binary scientific, true binary, and decimal values of the following weird-precision number? Biased Exp. = 9, Bias = 7, therefore: True Exponent = 2. 1.11101 2 2 (1 point for x.xxx 2 X, 1 point for bits, 1 point for exponent) 111.101 (1 point for whole, 1 point for fraction, OK if matches BiSci) 7 5 8 = 7.625 (1 point for whole, 1 point for fraction, accept either form) 0.0 Binary Scientific (3 points) True Binary (2 points) Decimal (2 points) D. (1 Point) Will the true binary number 1.01 2 9 fit into a weird-precision number? NO. (Bias is 7, so Biased Exponent = 7+9=16, but largest exponent 11102=14) Page 3

<3> 20 Points What are the decimal values of the following 32-bit binary number under each of the listed representations? If the value is illegal under the representation, say so. 11000001011000000000000000000000 C1600000 Illegal -1.11 2 3 = -1110 = -14 (accept any answer shown) 49504.0 Hexadecimal BCD 1101 is not a BCD digit Single Precision Floating Point Biased Exponent = 100000102 = 130, True Exponent = 130 127(bias) = 3 Unsigned Fixed Point, 16 whole and 16 fraction 1100000101100000.0000000000000000 Score each answer as 5 points. For answers with multiple digits, remove 1 point per error. Page 4

<4> 10 Points The image below shows the tree representation for an arithmetic expression (C and D are algebraic variables, #4 and #5 are just the numeric constants 4 and 5, 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. (5 4) * C C * (D / D) Remove 1 point per error. OK to write 5 as #5. Extra parentheses OK, as in: ((5 4) * C) (C * (D / D)) 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.) Score as 5 points, all-or-nothing. Optimization steps: 5 4 = 1, 1 * C = C, D / D = 1, C * 1 = C, C C = 0 Page 5

<5> 18 Points There are two 3D points <3,7,-2> and <7,13,-8>. What are the parametric equations in x, y, and z for the straight line that passes through the first point when t=0 and through the second point when t=1? x(t) = 4 t + 3 _ y(t) = 6 t + 7 _ z(t) = -6 t + -2 _ Three points each numerical answer. In each case the multiplier for t is the difference in the coordinate values for the corresponding dimension. The offset is the first of the two values by itself. For example, the multiplier for x(t) is the second x value minus the first x value, or 7 3 = 4, and the offset for x(t) is just the first x value, or 3. <6> 12 Points Short Answer For this problem, consider.wav and.mp3 sound files, as well as.bmp and.jpg graphics files, in the light of what we have learned about representations: How would you interpret the phrase.wav is to.mp3 as.bmp is to.jpg? How would you interpret the phrase.wav is to.bmp as.mp3 is to.jpg? Statement #1:.WAV is to.mp3 as.bmp is to.jpg In each pair the first type is uncompressed, while the second type is compressed using a lossy compression technique. Statement #2:.WAV is to.bmp as.mp3 is to.jpg The first pair are both uncompressed, while the second pair are both compressed using a lossy compression technique. I m looking for some understanding that both.wav and.bmp are full-size, uncompressed files containing all the information for their respective domains (audio or image), while both.mp3 and.jpg are compressed, and that the compression technique used in both cases is lossy. They can interpret the two phrases separately or together. Scoring: Score as 12 points if students address non-compression, compression, and lossy compression. Score as 6 points if the answer is basically OK but partially incomplete. Score as 0 points if the answer does not address any of these ideas. Page 6