Building a Test Suite

Similar documents
Administrivia. CMSC 216 Introduction to Computer Systems Lecture 24 Data Representation and Libraries. Representing characters DATA REPRESENTATION

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

Number Systems Prof. Indranil Sen Gupta Dept. of Computer Science & Engg. Indian Institute of Technology Kharagpur Number Representation

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

Basic data types. Building blocks of computation

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

CS101 Lecture 04: Binary Arithmetic

Data Storage and Query Answering. Data Storage and Disk Structure (4)

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

CHAPTER V NUMBER SYSTEMS AND ARITHMETIC

10.1. Unit 10. Signed Representation Systems Binary Arithmetic

MACHINE LEVEL REPRESENTATION OF DATA

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

World Inside a Computer is Binary

Inf2C - Computer Systems Lecture 2 Data Representation

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

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

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

LING 388: Computers and Language. Lecture 5

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

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

Data Representation COE 301. Computer Organization Prof. Muhamed Mudawar

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

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

Objectives. Connecting with Computer Science 2

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

Introduction to Computers and Programming. Numeric Values

Integer Data Types. Data Type. Data Types. int, short int, long int

Fundamental Data Types

M1 Computers and Data

ECE2049: Embedded Computing in Engineering Design C Term Spring Lecture #3: Of Integers and Endians (pt. 2)

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

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

Variables and Data Representation

Numeric Encodings Prof. James L. Frankel Harvard University

COMP2611: Computer Organization. Data Representation

CHW 261: Logic Design

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

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

Representation of Information

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

Computer System and programming in C

Lecture 25: Other Number Systems

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

COMP2121: Microprocessors and Interfacing. Number Systems

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

Numerical Representations On The Computer: Negative And Rational Numbers

Announcement. (CSC-3501) Lecture 3 (22 Jan 2008) Today, 1 st homework will be uploaded at our class website. Seung-Jong Park (Jay)

On a 64-bit CPU. Size/Range vary by CPU model and Word size.

Five classic components

Chapter 4: Data Representations


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

Digital Fundamentals

Chapter 2. Positional number systems. 2.1 Signed number representations Signed magnitude

Numerical Representations On The Computer: Negative And Rational Numbers

Number Systems CHAPTER Positional Number Systems

Data Representation in Computer Memory

Digital Fundamentals

Digital Computers and Machine Representation of Data

JAVA Programming Fundamentals

CSC201, SECTION 002, Fall 2000: Homework Assignment #2

Standard 11. Lesson 9. Introduction to C++( Up to Operators) 2. List any two benefits of learning C++?(Any two points)

Binary Representations and Arithmetic

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

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

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

Data Representation 1

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

Chapter 2. Data Representation in Computer Systems

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

a- As a special case, if there is only one symbol, no bits are required to specify it.

Integer Representation Floating point Representation Other data types

Module 3: Representing Values in a Computer

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

Final Labs and Tutors

Zheng-Liang Lu Java Programming 45 / 79

Private Institute of Aga NETWORK DATABASE LECTURER NIYAZ M. SALIH

Representing Information. Bit Juggling. - Representing information using bits - Number representations. - Some other bits - Chapters 1 and 2.3,2.

Signed umbers. Sign/Magnitude otation

Floating Point. CSE 351 Autumn Instructor: Justin Hsia

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

Data Representa+on in Memory

ECOM 2325 Computer Organization and Assembly Language. Instructor: Ruba A.Salamah INTRODUCTION

Introduction to Computer Science (I1100) Data Storage

Binary Addition & Subtraction. Unsigned and Sign & Magnitude numbers

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

Chapter 11 : Computer Science. Information Representation. Class XI ( As per CBSE Board) New Syllabus

CS107, Lecture 3 Bits and Bytes; Bitwise Operators

Representing Data Elements

EE 109 Unit 3. Analog vs. Digital. Analog vs. Digital. Binary Representation Systems ANALOG VS. DIGITAL

Hexadecimal Numbers. Journal: If you were to extend our numbering system to more digits, what digits would you use? Why those?

Programming Studio #1 ECE 190

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 Solutions 26 February 2014

Midterm Exam Review Slides

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

Adding Binary Integers. Part 5. Adding Base 10 Numbers. Adding 2's Complement. Adding Binary Example = 10. Arithmetic Logic Unit

UNIVERSITY OF WISCONSIN MADISON

Floating Point Numbers. Lecture 9 CAP

Transcription:

Program #3 Is on the web Exam #1 Announcements Today, 6:00 7:30 in Armory 0126 Makeup Exam Friday March 9, 2:00 PM room TBA Reading Notes (Today) Chapter 16 (Tuesday) 1

API: Building a Test Suite Int createemployee(char *lastname, char *firstname); Return unique id for that employee Int lookupemloyee(char *lastname, char *firstname, in *id); Return 0 on success, -1 on failure (not found or > 1 match) Fills out id on success fristname can be null Int deleteemployee(int id); Int setsalary(int id, float salary); 2

Possible Test Cases Int createemployee(char *lastname, char *firstname); Pass valid data Pass same last name, different first name Pass same last name, first name same as previous Pass null for lastname and/or for firstname Pass an lastname/firstname that has 10MB before null termination. Create 10,000 employees 3

Test Cases Continued Int lookupemloyee(char *lastname, char *firstname, in *id); Call before inserting anyone Lookup someone that was created Lookup someone with the same lastname, but different firstname Lookup null last/first names Pass id as null Int deleteemployee(int id); Pass valid id Pass invalid id Pass id of someone who has just been deleted Int setsalary(int id, float salary); Invalid id Negative salary 4

Representing Characters Need Represent common characters Have standards so computers can interoperate Common Formats ASCII 7 bits for characters (stored in 8 bits normally) most commonly used UNICODE family of encodings 8, 16, and 32 bits/character allow greater variety of characters Able to represent virtually character in use today and some no longer in use 5

ASCII Represents normal characters on US keyboards A-Z (101-132) a-z (141-172) 0-9 (60-71) punctuation:!@#$%^&*()_+-=[]{} \;:"'<>?,./ space <control-a> - <control-z> Also have other names <control-m> is CR (\r) 6

UNICODE Unicode Representations UTF-32 32 bit representation of all characters all characters are the same size wastes lots of space (2x UTF-16 for most things, 4x ascii for many things) UTF-16 16 bit representation of characters some characters are stored in two-character forms popular since most things can be represented in 16 bits UTF-8 8 bit representation of characters provides backwards compatibility with ascii low 7 bits are exactly ASCII high bit on indicates part of UNICODE extensions popular for web and other applications 7

All data stored in binary Representing Integers all numbers are 0 or 1 Unsigned numbers are stored using base 2 128 64 32 16 8 4 possible range 0 to 2 n where n is the number of bits Signed numbers are stored using two's complement left most bit indicates if a number is positive or negative 0 is positive 1 is a negative number 2 1 8

Adding Binary Numbers Add starting from right Carry if the number is too large to represent if it is greater than 1 1001 1001 1011 1101 + 10 + 11 + 11 +111 ------- ------- ------ ------ 9

2's complement representation To compute a negative value: flip all the bits of the positive value, add 1 Allows addition of signed and unsigned numbers Valid range of numbers -2 n-1 to 2 n-1-1 for n bits Example: 16 bit number -32,768 to 32,767 10

How do we represent real numbers? Each number has two parts mantissa (represents a number between -1 and 1) represented as a binary number i.e. 0.1 = 1/2 exponent (designates the position of the decimal point) uses normal two's complement form number = m r e where r is the radix 6132.789 = +0.6132789 x 10 4 Normalization convert to number between -1 and 1 if the most significant digit of mantissa is non-zero. 11

Floating Point Continued Computers normally use a radix of 2 Examples of floating point numbers 1001.11 =.1001110 x 2 4 10.5 = 1010.1 or 10101 x 2 4 17.451 = 111.011100 = 1110111 x 2 3 IEEE Floating point standard 32 bit floating point (float) 1 sign bit, 8 bits exponent, 23 bits mantissa 64 bit floating point (double) 1 sign bit, 11 bits exponent, 52 bits mantissa most common for real applications 128 bit floating point (quad) 1 sign bit, 15 bits exponent, 112 bits of mantissa 12