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

Similar documents
Time (self-scheduled): Location Schedule Your Exam: What to bring:

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

Midterm Exam Review Slides

COMP2611: Computer Organization. Data Representation

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

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

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

Introduction to Computer Science-103. Midterm

Computer System and programming in C

The type of all data used in a C++ program must be specified

Introduction to Computers and Programming. Numeric Values

Beginning C Programming for Engineers

BSM540 Basics of C Language

These are reserved words of the C language. For example int, float, if, else, for, while etc.

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

10.1. Unit 10. Signed Representation Systems Binary Arithmetic

15213 Recitation 2: Floating Point

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

Number Systems, Scalar Types, and Input and Output

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

Computer Systems Programming. Practice Midterm. Name:

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

Review Topics. Midterm Exam Review Slides

Computer Organization & Systems Exam I Example Questions

CPE 323 REVIEW DATA TYPES AND NUMBER REPRESENTATIONS IN MODERN COMPUTERS

CPE 323 REVIEW DATA TYPES AND NUMBER REPRESENTATIONS IN MODERN COMPUTERS

ECE232: Hardware Organization and Design

M1 Computers and Data

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

COMP2121: Microprocessors and Interfacing. Number Systems

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

MACHINE LEVEL REPRESENTATION OF DATA

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

CSCI 2212: Intermediate Programming / C Chapter 15

Chapter 3. Information Representation

The type of all data used in a C (or C++) program must be specified

Integer Representation Floating point Representation Other data types

CHAPTER V NUMBER SYSTEMS AND ARITHMETIC

Goals for this Week. CSC 2400: Computer Systems. Bits, Bytes and Data Types. Binary number system. Finite representations of binary integers

211: Computer Architecture Summer 2016

Chapter 4. Operations on Data

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

More about Binary 9/6/2016

Inf2C - Computer Systems Lecture 2 Data Representation

Full Name: CISC 360, Fall 2008 Example of Exam

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

Chapter 3: Arithmetic for Computers

Number Systems for Computers. Outline of Introduction. Binary, Octal and Hexadecimal numbers. Issues for Binary Representation of Numbers

CprE 281: Digital Logic

Computer Science 324 Computer Architecture Mount Holyoke College Fall Topic Notes: Bits and Bytes and Numbers

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

Review Topics. Midterm Exam Review Slides

Data Representation 1

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

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

Lecture 3. More About C

CPS 104 Computer Organization and Programming Lecture-2 : Data representations,

COMP Overview of Tutorial #2

Number Systems. Both numbers are positive

SIGNED AND UNSIGNED SYSTEMS

JAVA Programming Fundamentals

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

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

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

Fundamentals of Programming Session 2

CS 31: Intro to Systems Binary Representation. Kevin Webb Swarthmore College September 6, 2018

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

Topic Notes: Bits and Bytes and Numbers

Physics 306 Computing Lab 5: A Little Bit of This, A Little Bit of That

Exercises Software Development I. 03 Data Representation. Data types, range of values, internal format, literals. October 22nd, 2014

104 - Introduction to Computer Science - Midterm Exam

UNIVERSITY OF WISCONSIN MADISON

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

Bits, Words, and Integers

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

Numeric Encodings Prof. James L. Frankel Harvard University

ECE2049: Homework 1. Due: Thursday, 25 May 2017 by 7pm

Variables and Data Representation

FLOATING POINT NUMBERS

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

Topic Notes: Bits and Bytes and Numbers

Number Representations

Work relative to other classes

Final Labs and Tutors

Binary representation of integer numbers Operations on bits

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

Objects and Types. COMS W1007 Introduction to Computer Science. Christopher Conway 29 May 2003

A Java program contains at least one class definition.

Chapter 10 Binary Arithmetics

Basic data types. Building blocks of computation

Java Basic Datatypees

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

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

Internal representation. Bitwise operators

Computer Systems C S Cynthia Lee

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

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

CS 31: Intro to Systems Binary Representation. Kevin Webb Swarthmore College January 27, 2015

Today CISC124. Building Modular Code. Designing Methods. Designing Methods, Cont. Designing Methods, Cont. Assignment 1 due this Friday, 7pm.

Binary Representations and Arithmetic

Transcription:

ECE 120 Midterm 1 HKN Review Session Time: 8:30-10:00 pm (Arrive at 8:15 pm) Location: Your Room on Compass What to bring: icard, pens/pencils, Cheat sheet (Handwritten)

Overview of Review Binary IEEE floating point Hex & ASCII Operators Bitmasks C programming Practice Exam

Binary Representation Unsigned - k bits can represent [0, 2^k) values Can only represent non-negative integers Overflow Condition: If the most significant bit has a carry out Zero Extended - pad the front with zeros when moving to larger data type (10101) = (16+4+1) = 21 Signed Magnitude - (- 2^(k-1), 2^(k-1) ) values First bit determines sign of number ( 1 = negative, 0 = positive) (10101) = (-1) x (4+1) = -5

Binary Representation - Part II 2 s Complement - k bits represents [ -2^(k-1), 2^(k-1) - 1] Sign Extended - pad the front of the number with the sign bit when moving to larger data type Overflow Condition: if adding numbers of the same sign yields a result of the opposite sign If signed bit is 0, magnitude is same as if the number were treated as unsigned If signed bit is 1, to determine the magnitude, bitwise NOT the bits, and add 1 before finding magnitude 2 s complement provides a greater range of values and cleaner binary arithmetic operations ie. the same logic circuit used to add binary unsigned and 2 s complement numbers

ieee 754 Floating Point Representation Great for approximations & expressing very large/very small decimal values 1st bit is sign bit, 0 for positive and 1 for negative 2nd through 9th bit is exponent Special Cases: When exponent is 0 or 255, then denormalized or NAN/inf forms respectively. Denormalized format has normal sign, and magnitude: 0.mantissa * 2^(-126) NAN/inf form is NAN when mantissa is non-zero, and infinity (inf) when mantissa is all zeros 10th through 32nd bit is 23 bit mantissa Normal Form has magnitude of 1.mantissa * 2 ^ (exponent - 127) (-1)^sign * 1.fraction * 2^(exponent - 127)

Hexadecimal & ASCII Representations 7-bit ASCII table will be provided if necessary Although 7 bits, chars in C are 1 byte of memory and allocate 8 bits per character anyway Hexadecimal is base 16 number system (0-9 & A-F) All numbering systems that have a power of 2 base can have individual characters mapped to binary strings A=1010 B=1011 C=1100 D=1101 E=1110 F=1111 converting 76 (01001100) to hex = 0x4C 0111010, 0110011, 0101001 converting to ASCII -

Hexadecimal & ASCII Representations 7-bit ASCII table will be provided if necessary Although 7 bits, chars in C are 1 byte of memory and allocate 8 bits per character anyway Hexadecimal is base 16 number system (0-9 & A-F) All numbering systems that have a power of 2 base can have individual characters mapped to binary strings A=1010 B=1011 C=1100 D=1101 E=1110 F=1111 converting 76 (01001100) to hex = 0x4C 0111010, 0110011, 0101001 converting to ASCII - 0x3A 0x33 0x29 :3)

Operators AND Returns 1 if both inputs are 1 OR Returns 1 if any of the inputs are 1 XOR Returns 1 if either a or b is 1, not both NOT Returns opposite of input ( 0->1, vice versa)

Bitmasks Great for looking at only certain bits A bitmask using AND as the bitwise operator will selectively mask bits to 0 A bitmask using OR as the bitwise operator will selectively mask bits to 1

C programming Variables Double, Long (8 bytes) Int, Float (4 bytes) Int may be 2 bytes on some systems Short (2 bytes) Char (1 byte)

Format Specifiers and Escape Sequences Format Specifiers: %c char single character %d (%i) int signed integer %e (%E) float or double exponential format %f float or double signed decimal %g (%G) float or double use %f or %e as required %o int unsigned octal value %p pointer address stored in pointer %s array of char sequence of characters %u int unsigned decimal %x (%X) int unsigned hex value Escape Sequences: \n - new line character \b - backspace character \t - horizontal tab \ - allows for storing and printing of ASCII value in string \\ - allows for storing and printing of \ ASCII value in string \ - allows for storing and printing of ASCII value in string \? - allows for storing and printing of? ASCII value in string Ie. char x = \ ; (those are 2 single quotes) will store the data byte associated with into x

Format Specifier Example int integer = 5; float decimal = 2.5; printf( This is an integer: %d\nthis is a float: %f\n, integer, decimal);

Format Specifier Example int integer = 5; float decimal = 2.5; printf( This is an integer: %d\nthis is a float: %f\n, integer, decimal); Prints: This is an integer: 5 This is a float: 2.50000

C - operators Order of precedence *, /, %, then +, - (Note, Modular Arithmetic (%) is not defined for floating point numbers) Assignment operator Relational = (takes a variable on the left and a value/expression on the right side) Sets the variable on the left equal to the expression on the right IE, you can t do 5 = x; as 5 is not a variable (you can t assign a value to 5!) ==,!=, <, >, <=, >= Returns 1 for true, 0 for false Bitwise &,, ~, ^ (AND, OR, NOT, XOR) Logical!, &&, (NOT, AND, OR)

C operators - bitwise examples

C operators - bitwise examples c = 28 d = 7 e = 17

Basic Input / Output

Conditional Constructs

Conditional Constructs - Example

Iterative Constructs

Iterative - Example

HW2.9

Past Exam Review https://wiki.illinois.edu/wiki/display/ece120/midterm+1 Fall 2016, Midterm 1 Solutions available