Question 4: a. We want to store a binary encoding of the 150 original Pokemon. How many bits do we need to use?

Similar documents
University of California, Berkeley College of Engineering

COMP2611: Computer Organization. Data Representation

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

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

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

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

Inf2C - Computer Systems Lecture 2 Data Representation

Introduction to Computers and Programming. Numeric Values

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

COMP Overview of Tutorial #2

Numeric Encodings Prof. James L. Frankel Harvard University

Floating Point Arithmetic

10.1. Unit 10. Signed Representation Systems Binary Arithmetic

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

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

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

Floating Point Numbers. Lecture 9 CAP

CS 101: Computer Programming and Utilization

DRAM uses a single capacitor to store and a transistor to select. SRAM typically uses 6 transistors.

Data Representation. DRAM uses a single capacitor to store and a transistor to select. SRAM typically uses 6 transistors.

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

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

Numerical Representations On The Computer: Negative And Rational Numbers

l l l l l l l Base 2; each digit is 0 or 1 l Each bit in place i has value 2 i l Binary representation is used in computers

Chapter 3: Arithmetic for Computers

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

Decimal & Binary Representation Systems. Decimal & Binary Representation Systems

Numerical Representations On The Computer: Negative And Rational Numbers

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

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

M1 Computers and Data

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

Chapter 4. Operations on Data

Chapter Three. Arithmetic

Floating Point Numbers

Floating Point Numbers

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

Time: 8:30-10:00 pm (Arrive at 8:15 pm) Location What to bring:

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

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

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

CHAPTER V NUMBER SYSTEMS AND ARITHMETIC

FLOATING POINT NUMBERS

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

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

Systems Programming and Computer Architecture ( )

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

INTEGER REPRESENTATIONS

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

COMP2121: Microprocessors and Interfacing. Number Systems

CS 33. Data Representation (Part 3) CS33 Intro to Computer Systems VIII 1 Copyright 2018 Thomas W. Doeppner. All rights reserved.

CS 261 Fall Mike Lam, Professor Integer Encodings

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

Divide: Paper & Pencil

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

Number Systems. Both numbers are positive

Organisasi Sistem Komputer

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,...

Computer Organization: A Programmer's Perspective

unused unused unused unused unused unused

Data Representation in Computer Memory

Computer Organisation CS303

Chapter 4: Data Representations

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

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

Number System. Introduction. Decimal Numbers

World Inside a Computer is Binary

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

Declaration. Fundamental Data Types. Modifying the Basic Types. Basic Data Types. All variables must be declared before being used.

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

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

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

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

Floating Point January 24, 2008

Representing and Manipulating Floating Points. Jo, Heeseung

Integer Representation Floating point Representation Other data types

Data Representation 1

CO212 Lecture 10: Arithmetic & Logical Unit

Representing and Manipulating Floating Points

Integers and Floating Point

Data Representation Floating Point

CHW 261: Logic Design

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

CHAPTER 1 Numerical Representation

Data Representation Floating Point

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

CS 61C: Great Ideas in Computer Architecture. (Brief) Review Lecture


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

Foundations of Computer Systems

System Programming CISC 360. Floating Point September 16, 2008

Number Representations

Signed umbers. Sign/Magnitude otation

Topic Notes: Bits and Bytes and Numbers

Finite arithmetic and error analysis

ECE232: Hardware Organization and Design

Computer Arithmetic Ch 8

Binary Representations and Arithmetic

Computer Arithmetic Ch 8

SISTEMI EMBEDDED. Basic Concepts about Computers. Federico Baronti Last version:

Transcription:

Question 4: a. We want to store a binary encoding of the 150 original Pokemon. How many bits do we need to use? b. What is the encoding for Pikachu (#25)?

Question 2: Flippin Fo Fun (10 points, 14 minutes) Assume that the most significant bit (MSB) of x is a 0. We store the result of flipping x s bits into y. Interpreted in the following number representations, how large is the magnitude of y relative to the magnitude of x? Circle ONE choice per row. Unsigned y < x y = x y > x Can t Tell One s Complement y < x y = x y > x Can t Tell Two s Complement y < x y = x y > x Can t Tell Sign and Magnitude y < x y = x y > x Can t Tell Biased Notation (e.g. FP exponent) y < x y = x y > x Can t Tell

Question 2: This Problem is Like a Box of Chocolates (27 points, 48 minutes) a) In C, char is in fact a signed variable type. Assume we have 4 chars!= 0x00 loaded into a 32 bit int, one in each byte. Complete the function below that will negate the char in byte i of the int in place, with byte 0 being the least significant and byte 3 being the most significant. void negbyte(int *data, char i) { } ;

Question 1: Reppin Yo Numbas (10 points, 16 minutes) For this question, we are using 16 bit numerals. For Floating Point, use 1 sign bit, 5 exponent bits, and 10 mantissa bits. For Biased use a bias of 2 15 +1. a) Indicate in which representation(s) the numeral is closest to zero: Two s Complement (T), Floating Point (F), or Biased (B). The first one has been done for you. NaN is not valid in comparisons. Numeral: Closest to zero: 1) 0x0000 TF 2) 0xFFFF 3) 0x0001 4) 0xFFFE 5) 0x8000 6) 0x7FFF b) We now wish to add the numerals from top to bottom (1 to 6). However, it is possible that we encounter an error when performing these addition operations. For each number representation, state the FIRST error that is encountered and which numeral causes it; if no error is encountered, answer no error. Possible arithmetic errors are: OVERFLOW, UNDERFLOW, NaN, and ROUNDING (assume we are rounding using a truncating scheme). Representation: Arithmetic Error: Numeral #: Two s Complement Floating Point Biased

SID: Question 1: Number Representation (15 pts) a) Complete the tables below: Convert unsigned integers: Convert to and from IEC prefixes: Base 8 Hexadecimal Standard IEC Prefixes 115 8 16 Pebi-bits 0x1A 2048 students b) Due to limitations in storage space, we are using only 4 bits to represent integers. 1) What is the most negative 2 s complement signed integer (decimal) we can represent? 2) What is the value (decimal) of the 2 s complement number 0b1010? 3) Write a number (binary) that, when added to 0b0100, will cause signed overflow. c) An amino acid is defined by a set of 3 consecutive nucleotides (A, C, G, or T). For example, ATG is Methionine. All combinations are unique (e.g. ATG AGT GTA). 1) How many total possible amino acids are there? 2) In reality, there are 21 amino acids found in the human body. How many bits would it take to encode these amino acids in binary? 3) Scientists also use single-digit encodings for amino acids (e.g. A for Alanine). In a single sentence, explain why it is okay that we use A for the amino acid Alanine, the nucleotide adanine, and the hex representation of the decimal number 10. 4) We wish to encode the 21 amino acids in base 2, 3, or 5. Which of these choices allows for the MOST new amino acids discoveries before needing to increase the number of digits and how many new discoveries are allowed in this choice? Possible New Base: Discoveries: 2

SID: Question 2: C Potpourri (12 pts) a) Given the library function rand() that returns a random number between 0 and (2^32)-1 when called, write a valid C expression that uses bit operations (^, ~,, &)to initialize the variable r with a random integer between 0 and n, which is some power of 2 less than (2^32)-1. int n = 8; // In this case, we want r to contain one of {0,1,2,3,4,5,6,7}. int r = ;