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

Similar documents
Floating Point Arithmetic

Floating-point representations

Floating-point representations

Numeric Encodings Prof. James L. Frankel Harvard University

ECE232: Hardware Organization and Design

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

Floating Point Numbers

Inf2C - Computer Systems Lecture 2 Data Representation

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

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

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

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

COMP2611: Computer Organization. Data Representation

Computer Systems C S Cynthia Lee

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

System Programming CISC 360. Floating Point September 16, 2008

Floating Point : Introduction to Computer Systems 4 th Lecture, May 25, Instructor: Brian Railing. Carnegie Mellon

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

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

Foundations of Computer Systems

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

Divide: Paper & Pencil

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

Bryant and O Hallaron, Computer Systems: A Programmer s Perspective, Third Edition. Carnegie Mellon

M1 Computers and Data

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

10.1. Unit 10. Signed Representation Systems Binary Arithmetic

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

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

15213 Recitation 2: Floating Point

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

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

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

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

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

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

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

Floating Point January 24, 2008

Chapter 2 Data Representations

Introduction to Computers and Programming. Numeric Values

Giving credit where credit is due

Data Representation Floating Point

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

COMP Overview of Tutorial #2

Giving credit where credit is due

Data Representation Floating Point

Module 2: Computer Arithmetic

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

Data Representations & Arithmetic Operations

Chapter Three. Arithmetic

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

CprE 281: Digital Logic

Floating Point Numbers

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

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

Number Representations

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

Introduction to C. Why C? Difference between Python and C C compiler stages Basic syntax in C

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

COMP2121: Microprocessors and Interfacing. Number Systems

Today: Floating Point. Floating Point. Fractional Binary Numbers. Fractional binary numbers. bi bi 1 b2 b1 b0 b 1 b 2 b 3 b j

Floating Point. CSE 351 Autumn Instructor: Justin Hsia

CS61C : Machine Structures

3.5 Floating Point: Overview

CS356: Discussion #3 Floating-Point Operations. Marco Paolieri

Where we are going (today)

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

Floating Point. CSE 238/2038/2138: Systems Programming. Instructor: Fatma CORUT ERGİN. Slides adapted from Bryant & O Hallaron s slides

Where we are going (today)

Under the Hood: Data Representation. Computer Science 104 Lecture 2

Floating Point Numbers

Floating Point Numbers

Computational Methods CMSC/AMSC/MAPL 460. Representing numbers in floating point and associated issues. Ramani Duraiswami, Dept. of Computer Science

Floating Point. CSE 351 Autumn Instructor: Justin Hsia

CO212 Lecture 10: Arithmetic & Logical Unit

FLOATING POINT NUMBERS

Representing and Manipulating Floating Points

Floating Point. CSE 351 Autumn Instructor: Justin Hsia

Computer Organization: A Programmer's Perspective

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

CPE 323 REVIEW DATA TYPES AND NUMBER REPRESENTATIONS IN MODERN COMPUTERS

Chapter 3: Arithmetic for Computers

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

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

Floating Point Arithmetic

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

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

Binary Representations and Arithmetic

Where we are going (today)

Lecture 13: (Integer Multiplication and Division) FLOATING POINT NUMBERS

Representing and Manipulating Floating Points

CS429: Computer Organization and Architecture

CS61C : Machine Structures

Floating Point Numbers. Lecture 9 CAP

Overview. ELEC2041 Microprocessors and Interfacing. Lecture 7: Number Systems - II. March 2006.

Number System. Introduction. Decimal Numbers

CPE 323 REVIEW DATA TYPES AND NUMBER REPRESENTATIONS IN MODERN COMPUTERS

Where are we? Compiler. translating source code (C or Java) Programs to assembly language And linking your code to Library code

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

CS101 Introduction to computing Floating Point Numbers

Transcription:

CS61c Midterm Review (fa06) Number representation and Floating points From your friendly reader Number representation (See: Lecture 2, Lab 1, HW#1) KNOW: Kibi (2 10 ), Mebi(2 20 ), Gibi(2 30 ), Tebi(2 40 ), Pebi(2 50 ), Exbi(2 60 ), Zebi(2 70 ), Yobi (2 80 ) Know the Binary (0b), Octal (0), Decimal, Hexadecimal (0x) representation of numbers. o Example: 11112 = 178 = 15ten = Fhex or 0b1111 = 017 = 15 = 0xF Know how to convert from one base to another. Example: 1045 =4*5 0 +0*5 1 +1*5 2 = 29ten Know what is a bit, a Nibble, a Byte, a Word o Example: above example uses a Nibble! The lecture presents the evolution of number representation: sign and magnitude, one s complement, two s complement o Sign and Magnitude: *Left most bit represents the sign (0 == positive, 1 == negative), the rest represents magnitude. *In order to negate, flip the left most bit. * Can represent from (2 N-1-1) to 2 N-1-1 Cons: *We have two zeros, namely 0x00000000 and 0x80000000 *Arithmetic is non-trivial *Number comparison is non trivial ( -2 > -1 ) o One s Complement *Left most bit represents the sign. *In order to negate, must flip all the bits. * Can represent from (2 N-1-1) to 2 N-1-1 Cons: * Still have two zeros. * (x + (-x))!= 0, thus arithmetic is still complicated. o Two s Complement (standard) *Left most bit represents the sign. *In order to negate must flip bits and add 1. -x = flip_bits(x) +1 * Can represent from 2 N-1 to 2 N-1-1 Unsigned numbers can represent from 0 to 2 N -1 Know overflow: there isn t enough bits to express a number. E.g: MAX+1 causes overflow Big-Endian vs Little-Endian o Refers to the order in which BYTES are stored in memory o bits of the byte are stored as usual o Big-Endian: Big Units first (are on the left) Example: today s date representation in big-endian is 06/10/15

o Little-Endian: Little Units first. Example: today s date representation in little-endian is 15/10/06 Floating points (See: Lecture 15 and 16, Lab 6) S Exponent Significand rounding_bits o Significand also known as the Mantissa o Bias: in order to be able to represent tiny and huge values, usually is 2 e-1-1 for normalized numbers, where e is number of bits for E o Rounding bits: there are usually extra bits tagged on after the Significand in order to correct for rounding errors when doing arithmetic o Single Precision (32 bits): S is 1 bit, E is 8 bits, S is 23 bits, bias = 2 7-1 = 127 o Double Precision (64 bits): S is 1 bit, E is 11 bits, S is 52 bits, bias = 2 8-1 = 1023 Exponent size vs. Signficand size range vs. precision Important to know all types (Norm, zero, Denorm,, NaN) Hint: Green sheet can be very useful! Single Precision discussed below: ( * anything, S is Sign, E is Exponent, M is Mantissa) o Norm: S = *, 0 < E < 2 8-1, M = * Form: (-1) S *2 (E-127) *(1+Mantissa) o Zero: S = *, E = 0, M = 0 o Denorm Exponent (implied bias): -126 S = *, E = 0, M>0 Form: (-1) S *2 (-126) *(0+ Mantissa) o S = *, E = 2 8-1 (all ones), M = 0 o NaN: S = *, E = 2 8-1 (all ones), M > 0 Double Precision is analogous to above, with exception of E range and the bias (implied bias for Denorm is -1022) Floating point addition: o See http://www.ecs.umass.edu/ece/koren/arith/simulator/fpadd/ for a good simulation for floating point addition/subtraction. Make sure you understand what is going on! o Steps: Align exponents (biggest exponent wins!) Normalize the result Round Extra bits tagged on at the end of the 32bits (64bits) for rounding error

Types: Round to zero, Round to nearest even, Round to, etc. Somewhat-trivial Questions: 1) What is 0xffff ffff in decimal form (you can use *2 y in your answer) o Unsigned int: o Sign and magnitude: o One s complement: o Two s complement: 2) J-Lo, who is thirty-six of age (as of fa05), whispers her age to you: Thirty six. Was that big-endian or little-endian (mt fa05) 3) Let x = 0xffff ffff. What is the decimal value (if any) using Single Precision floats? 4) Let x = 0x0040 0000. What is the decimal value (if any) using Single Precision floats? 5) What is a mebi? Conceptual/Midterm type Questions: 6) Let x = 0x4000 0000 and y = 0x0040 0000 be floats. What is x+y? 7) What is minimum positive float x such that x + 1 = x (You ve done this before in lab, and this has been on the Midterm before!)

8) True/False: Float arithmetic is associative. i.e. (x+y)+z = x+(y+z). If not, show a counterexample. 9) Let float x=2 20, find float y such that x+y have 0xb11 in the rounding bits on the alignment step (assume there are 2 such bits) i.e. x = 1.********** ********** *** 00 * 2 n y = *.********** ********** *** 00 * 2 n x + y = *.********** ********** *** 11 * 2 n Compute x+y, using truncation. Compute x+y using Round to zero

Compute x+y using round to Plus Infinity From Dan s previous Midterm (fa05) (Perhaps b should be done before a ) b) What is min, max, and positive min (greater than 0) for each of the types specified above? Type: Min max positive (normalized) min (>0) Unsigned int Sign-Magnitude 2s complement Float c) What is the largest integer that a float/double can store?

d) What is the largest integer that float/double can t store?