CMU MSP 36601: Computer Hardware and Data Representation

Size: px
Start display at page:

Download "CMU MSP 36601: Computer Hardware and Data Representation"

Transcription

1 CMU MSP 36601: Computer Hardware and Data Representation H. Seltman, September 6, Warm-up in R a. > == 0.3 [1] FALSE b. > 1e15+1e32 == 1e32 [1] TRUE c. > 1e-324 == 0 [1] TRUE d. > 1e-324 / 1e-325 [1] NaN e. > as.integer(c(2e9, 3e9)) [1] NA Warning message: NAs introduced by coercion to integer range f. > == [1] TRUE g. > exp(709) [1] e+307 h. > exp(710) [1] Inf 2. Hardware a. Roughly, your computer consists of: i. A clock whose ticks coordinate everything else. The speed of the computer is rated by the clock speed, e.g, 1.6GHz is 1.6 x 10 9 cycles per second. ii. A Central Processing Unit that interprets instructions (machine language) and performs basic data manipulation and calculation. The CPU consists of: 1. A Control Unit which controls everything else 2. Registers (on-cpu memory) that hold numbers and memory addresses (the size of the registers is the size of the CPU, e.g., 32 vs. 64 bits) 3. An Arithmetic-Logic Unit interprets instructions and performs integer and bit-wise operations 4. A Floating-Point-Unit which holds non-integer values in floating point registers and performs mathematical operations on them iii. Busses (more like highways) that carry the flow of data between parts of the computer iv. Non-volatile Read-Only Memory containing the Basic Input Output System which is the small, fixed, initial set of instructions the computer needs to load in the full operating system (usually from a disk). v. Volatile Random-Access Memory that is the working memory of the computer (often supplemented by cache memory more closely associated with the CPU) vi. Non-volatile user-writable storage (hard drive or solid-state storage) for storing programs and data when the computer is powered off or the RAM capacity is exceeded. Programs/data must be moved to RAM to be run/used. vii. Input/output devices: keyboard, mouse, video display, network adaptor viii. Optional additional hardware, e.g., USB port, expansion cards (such as a TV tuner) 1

2 b. Useful facts based on hardware knowledge i. Based on the CPU make and model, very different machine language may be supported. Therefore, programs compiled on one machine may not run on another. ii. The most basic operations in the CPU are: interpretation of machine language instructions in order; conditional branching to alternate instruction points; transfer of data into and out of registers; and performance of logical and mathematical operations on data in registers. iii. Modern machine language instruction sets have special hardware capabilities to perform repeated tasks on contiguous streams of data. Therefore, depending on how matrix data is stored, there may be a large difference in speed between row vs. column operations. iv. Data in RAM is individually addressable and very fast. (Cache memory is significantly faster.) Data from hard drives or solid-state storage are addressed in blocks, which are transferred to RAM before being used. Hard drive access is typically 10 to 50 times slower than RAM access. Programs that intelligently store data that will be used soon in cache are faster than those that do not. v. Operating systems usually implement virtual memory to allow more and bigger programs to run than would be possible with the available RAM. This is based on mapping some hard drive space as if it were RAM. When the fake RAM is needed, it is swapped with some real RAM, causing a large delay. When this happens frequently, it is called thrashing. 3. Software a. The Operating System provides services and coordination (via interfaces) i. Program execution ii. Multi-tasking and interrupts iii. Memory management iv. Disk management (file system) v. Device use and sharing (e.g., keyboard and display) vi. Security vii. Networking viii. The interface is a GUI (e.g., Windows), command line, and/or interrupts b. Programs must request services from the operating system, and this is relatively slow. c. Programs writing i. Programs may be written in machine language and then directly executed ii. Practically, very low-level programs are written in assembly language, which adds tools such as address names, instruction mnemonics, and macros to the basic machine language. iii. Compilers are programs that input their own language and output machine language (including calls to the operating system where needed) iv. Interpreters are programs that input their own language and output machine language that will be executed immediately or an interpreter-specific intermediate bytecode that can be run immediately or later using a virtual machine specific to that interpreter on your or a different computer. 2

3 4. Data Representation a. It is true that everything is bits! Your RAM or hard drive is best thought of as a single long string of bits (e.g., 16GB of RAM is 16*10 9 *8 bits). Depending on the device, bits are physically represented as electrical or magnetic patterns with two states. All further discussion need only focus on the arbitrary names 0 and 1. b. Bits can be thought of in aggregation: i. Nibble: 4 bits ii. Byte: 8 bits iii. Word: usually 16, 32, or 64 bytes c. Math review of numeric bases i. In base b, digits go from 0 to b-1 (b of them), columns from right to left are 1 s, b s, b 2 s, b 3 s, etc., and 10 b always represents b, i.e., 1 b s. ii. Examples Base Digits ABCDEF A 10 2B d. For convenience we can represent a bit pattern in several ways other than 0/1: i. Decimal: ( ) = 93 ( or 64+3*8+5 or 5*16+13) ii. Group by 3s is octal: = 135 octal (1, 2+1, 4+1) [strtoi("135",8) in R] iii. Group by 4s is hexadecimal: = 5D (4+1, 8+4+1) [0x5D in R 5Dx elsewhere] e. Nerd joke: Why do computer nerds confuse Halloween with Christmas? (see next page for answer) f. Central fact: n bits can represent 2 n things g. **** What a set of bits represents depends entirely on context **** h. Context: Machine language instructions are arbitrary mappings with a variable number of bytes A small made-up example of a set of machine language instructions: : stop to : increment registers A through D to : decrement registers A through D : A <- A + B : A <- A B : A <- A * B : A <- A / B aaaa aaaa aaaa aaaa: load A from aaaa aaaa aaaa aaaa aaaa aaaa aaaa aaaa: store A in to aaaa aaaa aaaa aaaa aaaa aaaa: jump ahead aaaa aaaa instructions if A== aaaa aaaa aaaa aaaa: jump to aaaa aaaa aaaa aaaa if A==0 Etc. 3

4 i. Nerd joke answer: 31OCT = 25DEC j. Context: English text coded as ASCII (0b bbb bbb, written in octal) A : 101 a : 141 : 40 0 : 30,-. : LineFeed: 10 CarriageReturn: 13 Abde 4321 Baa. : k. Context: Text as UTF-8 Unicode 1. Format: 0bbbbbbb or 110bbbbb 10bbbbbb or 1110bbbb 10bbbbbb 10bbbbbb or 11110bbb 10bbbbbb 10bbbbbb 10bbbbbb 2. Possible values: 127 single-byte codes two-byte codes three-byte codes four-byte codes (135,268,479 possible characters and symbols) 3. Backward compatible with 7-bit ASCII and self-synchronizing 4. Allows accents, Hangul alphabet, Chinese ideographs (~80K), math symbols, etc. 5. Example: Abstractly: 2*β": ASCII hex 22, 2A plus UTF-8 U+03B2 In R: "2*\u3B2" [3=_011, B=1011, 2=0010] b bb/bb 10bb/ bbbb l. Context: Integers 1. Short (2 bytes) representing 2 16 values i. (INT) Signed: -32,768 to +32,767 using two s complement ii. (UINT) Unsigned: 0 to 65, Long (4 [or 8] bytes) representing 2 32 [or 2 64 ] values i. (LONG) Signed: -2,147,483,649 to +2,147,483,648 ii. (ULONG) Unsigned: 0 to 4,294,967, long long (twice the length of long) 2 10 = *10 18 m. Context: memory address (pointer) generally 32 (4GB RAM) or 64 bits (4 million TB) n. Context: Simplified bit-mapped 256 level grey-scale image (max 65,535 x 65,535) UINT rows; UINT cols; BYTES for row 0; ; BYTES for last row o. Context: Highly simplified file system header UINT number of files; repeat for each file{short flags (executable, write protected, etc.); LONG location of file on disk; BYTES*32 file name in ASCII} p. Context: Excel document Complex proprietary format, partially decodable q. Context: R objects (rough idea) TYPE (NULL vs. symbol vs. pairlist vs. function vs. environment ) LENGTH FLAGS for debug, garbage collection, etc. POINTER TO ATTRIBUTE NAME/VALUE pairs POINTER TO ACTUAL DATA 4

5 5. Miscellany r. Math review of floating point represents 6* * * * * * Of course, irrational numbers cannot be represented exactly in finite digits 3. 1/3=0.333 is rational, but cannot be represented exactly in finite digits in base 10, but is exactly equal to 1*3-1 in base Any irreducible fraction whose denominator is not factorable by 2 and 5 cannot be represented in finite digits in base is 1*2 2 +1*2 0 +1*2-2 +1*2-3 = 4+1+1/4+1/8 = 5 3/8 = Any irreducible fraction whose denominator is not factorable by 2 cannot be represented in finite digits in base 2. E.g., 1/5 = Scientific notation in base 2: e.g., = * 2 3 (note that this mantissa only requires 5, not 6, bits of storage). s. Context: IEEE Standard #754 Floating Point numbers 1. most common version is binary64 (double precision) 2. one bit is reserved for the sign 3. 52(53) bits for the mantissa gives significant decimal digits bits for the exponent gives a range of to ± special patterns are reserved for +, -, and Not A Number a. Typically, programs have access to RAM in two forms: stacks and heaps b. Stacks are fixed size, First-In-Last-Out mechanisms for storage. Data goes in and out via push and pop. Stacks play a key role in running functions. i. When one function transfers control to another function and expects to regain control later, the calling function pushes its next code address onto the stack before setting the program pointer to the start of the called function. When any function completes by reaching its return instruction, it transfers control to the address on the top of the stack, which automatically functions as return to caller, no matter which function called the current function and no matter how deep. ii. In programs like C and R, the calling function pushes all of the arguments for the function being called onto the stack after pushing the return code address onto the stack. In this system, all functions start by popping their arguments off of the stack, leaving the return address of the calling function on top. One language choice is to place (a copy of) the value of the argument on the stack ( call by value ) in which case the calling function cannot change the original value. An alternate choice is to place the address of the argument on the stack ( call by reference ), in which case the calling function does have the opportunity to change the original value. iii. Functions designed to return values push those values on the stack before returning so that the calling function can access them. 5

6 c. Heaps are blocks (really linear segments) of RAM that the program asks for. If the request is successful, the operating system return the starting address to the program. i. The process is usually called memory allocation. The program asks for a block of a certain size, and the operating system assigns the block to the program or reports that a block of that size is not available. ii. A program may explicitly release ( free ) memory that it no longer needs back to the operating system. Programs that do a lot of allocation and freeing may leave the available memory fragmented (analogous to disk fragmentation), and some mechanism for garbage collection may be required periodically, when a large enough block is not available and/or when the program explicitly requests it. This may involve massive movements of data and be very slow. iii. Also note that if, e.g., R asks for a numeric vector of size 1024, and then you run vec = c(vec, 2.5), R may need to ask the OS to allocate a larger block, copy all 1024 bytes to the new memory block, copy the 2.5 on to the end, and then free the original block. This may be very slow. Therefore, whenever possible allocate the full vector length you need up front. d. Typically, the stack and the heap grow towards each other resulting in a combined limit, but the OS may allow separate limits. Exceeding the stack size gives a stack overflow error. Exceeding the heap gives an error message such as out of memory. e. In R, memory.size() shows MB of heap allocated, memory.limit() shows total MB of heap available, and object.size(a) shows the size of object a. See limit in Unix. 6. Concluding remarks a. On the vast majority of computer systems, anything other than integer or FP vectors is non-fundamental. NA is also non-fundamental. b. Testing equality of FP values may be dangerous. In R, all.equal() appropriately tests for approximate FP equality (but returns TRUE or a string detailing differences). > x=0; for (i in 1:10) {x=x+0.1; if (x==0.3) print(x)} > x=0; for (i in 1:10) {x=x+0.1; if (istrue(all.equal(x, 0.3))) print(x)} [1] 0.3 c. Pay attention to heap memory allocation to improve efficiency. d. You should now understand the difference between human-readable and non-human readable files. You may be able to use published file format information or deduction to read non-human readable files. (Start with tools like FileAlyzer in Windows or hexdump -C" in Linux.) e. Beware of numeric overflow and underflow. f. Realize that compiled programs tend to be faster than interpreted ones. g. In a human readable file, is 10 bytes long; when read into R, SAS, etc. it will programmatically be converted to its bit FP pattern (always 8 bytes). 6

Lecture 03 Bits, Bytes and Data Types

Lecture 03 Bits, Bytes and Data Types Lecture 03 Bits, Bytes and Data Types Computer Languages A computer language is a language that is used to communicate with a machine. Like all languages, computer languages have syntax (form) and semantics

More information

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

Course Schedule. CS 221 Computer Architecture. Week 3: Plan. I. Hexadecimals and Character Representations. Hexadecimal Representation Course Schedule CS 221 Computer Architecture Week 3: Information Representation (2) Fall 2001 W1 Sep 11- Sep 14 Introduction W2 Sep 18- Sep 21 Information Representation (1) (Chapter 3) W3 Sep 25- Sep

More information

10.1. Unit 10. Signed Representation Systems Binary Arithmetic

10.1. Unit 10. Signed Representation Systems Binary Arithmetic 0. Unit 0 Signed Representation Systems Binary Arithmetic 0.2 BINARY REPRESENTATION SYSTEMS REVIEW 0.3 Interpreting Binary Strings Given a string of s and 0 s, you need to know the representation system

More information

The CPU and Memory. How does a computer work? How does a computer interact with data? How are instructions performed? Recall schematic diagram:

The CPU and Memory. How does a computer work? How does a computer interact with data? How are instructions performed? Recall schematic diagram: The CPU and Memory How does a computer work? How does a computer interact with data? How are instructions performed? Recall schematic diagram: 1 Registers A register is a permanent storage location within

More information

Digital Computers and Machine Representation of Data

Digital Computers and Machine Representation of Data Digital Computers and Machine Representation of Data K. Cooper 1 1 Department of Mathematics Washington State University 2013 Computers Machine computation requires a few ingredients: 1 A means of representing

More information

Final Exam. 11 May 2018, 120 minutes, 26 questions, 100 points

Final Exam. 11 May 2018, 120 minutes, 26 questions, 100 points Name: CS520 Final Exam 11 May 2018, 120 minutes, 26 questions, 100 points The exam is closed book and notes. Please keep all electronic devices turned off and out of reach. Note that a question may require

More information

Some Basic Concepts EL6483. Spring EL6483 Some Basic Concepts Spring / 22

Some Basic Concepts EL6483. Spring EL6483 Some Basic Concepts Spring / 22 Some Basic Concepts EL6483 Spring 2016 EL6483 Some Basic Concepts Spring 2016 1 / 22 Embedded systems Embedded systems are rather ubiquitous these days (and increasing rapidly). By some estimates, there

More information

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

IT 1204 Section 2.0. Data Representation and Arithmetic. 2009, University of Colombo School of Computing 1 IT 1204 Section 2.0 Data Representation and Arithmetic 2009, University of Colombo School of Computing 1 What is Analog and Digital The interpretation of an analog signal would correspond to a signal whose

More information

Practical Malware Analysis

Practical Malware Analysis Practical Malware Analysis Ch 4: A Crash Course in x86 Disassembly Revised 1-16-7 Basic Techniques Basic static analysis Looks at malware from the outside Basic dynamic analysis Only shows you how the

More information

Foundations of Computer Systems

Foundations of Computer Systems 18-600 Foundations of Computer Systems Lecture 4: Floating Point Required Reading Assignment: Chapter 2 of CS:APP (3 rd edition) by Randy Bryant & Dave O Hallaron Assignments for This Week: Lab 1 18-600

More information

Memory Addressing, Binary, and Hexadecimal Review

Memory Addressing, Binary, and Hexadecimal Review C++ By A EXAMPLE Memory Addressing, Binary, and Hexadecimal Review You do not have to understand the concepts in this appendix to become well-versed in C++. You can master C++, however, only if you spend

More information

Representation of Information

Representation of Information Representation of Information CS61, Lecture 2 Prof. Stephen Chong September 6, 2011 Announcements Assignment 1 released Posted on http://cs61.seas.harvard.edu/ Due one week from today, Tuesday 13 Sept

More information

Topics Power tends to corrupt; absolute power corrupts absolutely. Computer Organization CS Data Representation

Topics Power tends to corrupt; absolute power corrupts absolutely. Computer Organization CS Data Representation Computer Organization CS 231-01 Data Representation Dr. William H. Robinson November 12, 2004 Topics Power tends to corrupt; absolute power corrupts absolutely. Lord Acton British historian, late 19 th

More information

Summary of Computer Architecture

Summary of Computer Architecture Summary of Computer Architecture Summary CHAP 1: INTRODUCTION Structure Top Level Peripherals Computer Central Processing Unit Main Memory Computer Systems Interconnection Communication lines Input Output

More information

Topic Notes: Bits and Bytes and Numbers

Topic Notes: Bits and Bytes and Numbers Computer Science 220 Assembly Language & Comp Architecture Siena College Fall 2010 Topic Notes: Bits and Bytes and Numbers Binary Basics At least some of this will be review, but we will go over it for

More information

9/23/15. Agenda. Goals of this Lecture. For Your Amusement. Number Systems and Number Representation. The Binary Number System

9/23/15. Agenda. Goals of this Lecture. For Your Amusement. Number Systems and Number Representation. The Binary Number System For Your Amusement Number Systems and Number Representation Jennifer Rexford Question: Why do computer programmers confuse Christmas and Halloween? Answer: Because 25 Dec = 31 Oct -- http://www.electronicsweekly.com

More information

Why Don t Computers Use Base 10? Lecture 2 Bits and Bytes. Binary Representations. Byte-Oriented Memory Organization. Base 10 Number Representation

Why Don t Computers Use Base 10? Lecture 2 Bits and Bytes. Binary Representations. Byte-Oriented Memory Organization. Base 10 Number Representation Lecture 2 Bits and Bytes Topics! Why bits?! Representing information as bits " Binary/Hexadecimal " Byte representations» numbers» characters and strings» Instructions! Bit-level manipulations " Boolean

More information

Final Labs and Tutors

Final Labs and Tutors ICT106 Fundamentals of Computer Systems - Topic 2 REPRESENTATION AND STORAGE OF INFORMATION Reading: Linux Assembly Programming Language, Ch 2.4-2.9 and 3.6-3.8 Final Labs and Tutors Venue and time South

More information

Floating Point January 24, 2008

Floating Point January 24, 2008 15-213 The course that gives CMU its Zip! Floating Point January 24, 2008 Topics IEEE Floating Point Standard Rounding Floating Point Operations Mathematical properties class04.ppt 15-213, S 08 Floating

More information

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

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 198:211 Computer Architecture Topics: Lecture 8 (W5) Fall 2012 Data representation 2.1 and 2.2 of the book Floating point 2.4 of the book Computer Architecture What do computers do? Manipulate stored information

More information

COMP2121: Microprocessors and Interfacing. Number Systems

COMP2121: Microprocessors and Interfacing. Number Systems COMP2121: Microprocessors and Interfacing Number Systems http://www.cse.unsw.edu.au/~cs2121 Lecturer: Hui Wu Session 2, 2017 1 1 Overview Positional notation Decimal, hexadecimal, octal and binary Converting

More information

Topic Notes: Bits and Bytes and Numbers

Topic Notes: Bits and Bytes and Numbers Computer Science 220 Assembly Language & Comp Architecture Siena College Fall 2011 Topic Notes: Bits and Bytes and Numbers Binary Basics At least some of this will be review for most of you, but we start

More information

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

The type of all data used in a C (or C++) program must be specified The type of all data used in a C (or C++) program must be specified A data type is a description of the data being represented That is, a set of possible values and a set of operations on those values

More information

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

Introduction to C. Why C? Difference between Python and C C compiler stages Basic syntax in C Final Review CS304 Introduction to C Why C? Difference between Python and C C compiler stages Basic syntax in C Pointers What is a pointer? declaration, &, dereference... Pointer & dynamic memory allocation

More information

Experimental Methods I

Experimental Methods I Experimental Methods I Computing: Data types and binary representation M.P. Vaughan Learning objectives Understanding data types for digital computers binary representation of different data types: Integers

More information

Computer Architecture Review. Jo, Heeseung

Computer Architecture Review. Jo, Heeseung Computer Architecture Review Jo, Heeseung Computer Abstractions and Technology Jo, Heeseung Below Your Program Application software Written in high-level language System software Compiler: translates HLL

More information

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

The type of all data used in a C++ program must be specified The type of all data used in a C++ program must be specified A data type is a description of the data being represented That is, a set of possible values and a set of operations on those values There are

More information

Inf2C - Computer Systems Lecture 2 Data Representation

Inf2C - Computer Systems Lecture 2 Data Representation Inf2C - Computer Systems Lecture 2 Data Representation Boris Grot School of Informatics University of Edinburgh Last lecture Moore s law Types of computer systems Computer components Computer system stack

More information

Final Exam. 12 December 2018, 120 minutes, 26 questions, 100 points

Final Exam. 12 December 2018, 120 minutes, 26 questions, 100 points Name: CS520 Final Exam 12 December 2018, 120 minutes, 26 questions, 100 points The exam is closed book and notes. Please keep all electronic devices turned off and out of reach. Note that a question may

More information

Beyond Base 10: Non-decimal Based Number Systems

Beyond Base 10: Non-decimal Based Number Systems Beyond Base : Non-decimal Based Number Systems What is the decimal based number system? How do other number systems work (binary, octal and hex) How to convert to and from nondecimal number systems to

More information

Data Representation 1

Data Representation 1 1 Data Representation Outline Binary Numbers Adding Binary Numbers Negative Integers Other Operations with Binary Numbers Floating Point Numbers Character Representation Image Representation Sound Representation

More information

Why Don t Computers Use Base 10? Lecture 2 Bits and Bytes. Binary Representations. Byte-Oriented Memory Organization. Base 10 Number Representation

Why Don t Computers Use Base 10? Lecture 2 Bits and Bytes. Binary Representations. Byte-Oriented Memory Organization. Base 10 Number Representation Lecture 2 Bits and Bytes Topics Why bits? Representing information as bits Binary/Hexadecimal Byte representations» numbers» characters and strings» Instructions Bit-level manipulations Boolean algebra

More information

National 5 Computing Science Software Design & Development

National 5 Computing Science Software Design & Development National 5 Computing Science Software Design & Development 1 Stages of Development 2 Analysis 3 Design 4 Implementation 5 Testing 6 Documentation 7 Evaluation 8 Maintenance 9 Data Types & Structures 10

More information

Bits and Bytes January 13, 2005

Bits and Bytes January 13, 2005 15-213 The Class That Gives CMU Its Zip! Topics Bits and Bytes January 13, 25 Why bits? Representing information as bits Binary / Hexadecimal Byte representations» Numbers» Characters and strings» Instructions

More information

Course overview. Computer Organization and Assembly Languages Yung-Yu Chuang 2006/09/18. with slides by Kip Irvine

Course overview. Computer Organization and Assembly Languages Yung-Yu Chuang 2006/09/18. with slides by Kip Irvine Course overview Computer Organization and Assembly Languages Yung-Yu Chuang 2006/09/18 with slides by Kip Irvine Logistics Meeting time: 9:10am-12:10pm, Monday Classroom: CSIE Room 102 Instructor: Yung-Yu

More information

Variables and Data Representation

Variables and Data Representation You will recall that a computer program is a set of instructions that tell a computer how to transform a given set of input into a specific output. Any program, procedural, event driven or object oriented

More information

Princeton University Computer Science 217: Introduction to Programming Systems. Goals of this Lecture. Number Systems and Number Representation

Princeton University Computer Science 217: Introduction to Programming Systems. Goals of this Lecture. Number Systems and Number Representation Princeton University Computer Science 27: Introduction to Programming Systems Goals of this Lecture and Number Representation Help you learn (or refresh your memory) about: The binary, hexadecimal, and

More information

M1 Computers and Data

M1 Computers and Data M1 Computers and Data Module Outline Architecture vs. Organization. Computer system and its submodules. Concept of frequency. Processor performance equation. Representation of information characters, signed

More information

Topics. Hardware and Software. Introduction. Main Memory. The CPU 9/21/2014. Introduction to Computers and Programming

Topics. Hardware and Software. Introduction. Main Memory. The CPU 9/21/2014. Introduction to Computers and Programming Topics C H A P T E R 1 Introduction to Computers and Programming Introduction Hardware and Software How Computers Store Data Using Python Introduction Computers can be programmed Designed to do any job

More information

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

Number Systems Standard positional representation of numbers: An unsigned number with whole and fraction portions is represented as: N Number Systems Standard positional representation of numbers: An unsigned number with whole and fraction portions is represented as: a n a a a The value of this number is given by: = a n Ka a a a a a

More information

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

Floating Point Puzzles The course that gives CMU its Zip! Floating Point Jan 22, IEEE Floating Point. Fractional Binary Numbers. class04.ppt 15-213 The course that gives CMU its Zip! Topics Floating Point Jan 22, 2004 IEEE Floating Point Standard Rounding Floating Point Operations Mathematical properties Floating Point Puzzles For

More information

211: Computer Architecture Summer 2016

211: Computer Architecture Summer 2016 211: Computer Architecture Summer 2016 Liu Liu Topic: C Programming Data Representation I/O: - (example) cprintf.c Memory: - memory address - stack / heap / constant space - basic data layout Pointer:

More information

Number Systems and Number Representation

Number Systems and Number Representation Princeton University Computer Science 217: Introduction to Programming Systems Number Systems and Number Representation Q: Why do computer programmers confuse Christmas and Halloween? A: Because 25 Dec

More information

Representing numbers on the computer. Computer memory/processors consist of items that exist in one of two possible states (binary states).

Representing numbers on the computer. Computer memory/processors consist of items that exist in one of two possible states (binary states). Representing numbers on the computer. Computer memory/processors consist of items that exist in one of two possible states (binary states). These states are usually labeled 0 and 1. Each item in memory

More information

Scientific Computing. Error Analysis

Scientific Computing. Error Analysis ECE257 Numerical Methods and Scientific Computing Error Analysis Today s s class: Introduction to error analysis Approximations Round-Off Errors Introduction Error is the difference between the exact solution

More information

Page 1. Where Have We Been? Chapter 2 Representing and Manipulating Information. Why Don t Computers Use Base 10?

Page 1. Where Have We Been? Chapter 2 Representing and Manipulating Information. Why Don t Computers Use Base 10? Where Have We Been? Class Introduction Great Realities of Computing Int s are not Integers, Float s are not Reals You must know assembly Memory Matters Performance! Asymptotic Complexity It s more than

More information

Floating Point Arithmetic

Floating Point Arithmetic Floating Point Arithmetic CS 365 Floating-Point What can be represented in N bits? Unsigned 0 to 2 N 2s Complement -2 N-1 to 2 N-1-1 But, what about? very large numbers? 9,349,398,989,787,762,244,859,087,678

More information

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

9/3/2015. Data Representation II. 2.4 Signed Integer Representation. 2.4 Signed Integer Representation Data Representation II CMSC 313 Sections 01, 02 The conversions we have so far presented have involved only unsigned numbers. To represent signed integers, computer systems allocate the high-order bit

More information

Why Study Assembly Language?

Why Study Assembly Language? Why Study Assembly Language? This depends on the decade in which you studied assembly language. 1940 s You cannot study assembly language. It does not exist yet. 1950 s You study assembly language because,

More information

The x86 Microprocessors. Introduction. The 80x86 Microprocessors. 1.1 Assembly Language

The x86 Microprocessors. Introduction. The 80x86 Microprocessors. 1.1 Assembly Language The x86 Microprocessors Introduction 1.1 Assembly Language Numbering and Coding Systems Human beings use the decimal system (base 10) Decimal digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 Computer systems use the

More information

CS367 Test 1 Review Guide

CS367 Test 1 Review Guide CS367 Test 1 Review Guide This guide tries to revisit what topics we've covered, and also to briefly suggest/hint at types of questions that might show up on the test. Anything on slides, assigned reading,

More information

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

EE 109 Unit 19. IEEE 754 Floating Point Representation Floating Point Arithmetic 1 EE 109 Unit 19 IEEE 754 Floating Point Representation Floating Point Arithmetic 2 Floating Point Used to represent very small numbers (fractions) and very large numbers Avogadro s Number: +6.0247 * 10

More information

538 Lecture Notes Week 1

538 Lecture Notes Week 1 538 Clowes Lecture Notes Week 1 (Sept. 6, 2017) 1/10 538 Lecture Notes Week 1 Announcements No labs this week. Labs begin the week of September 11, 2017. My email: kclowes@ryerson.ca Counselling hours:

More information

SOME ASSEMBLY REQUIRED

SOME ASSEMBLY REQUIRED SOME ASSEMBLY REQUIRED Assembly Language Programming with the AVR Microcontroller TIMOTHY S. MARGUSH CRC Press Taylor & Francis Group CRC Press is an imprint of the Taylor & Francis Croup an Informa business

More information

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

CS 265. Computer Architecture. Wei Lu, Ph.D., P.Eng. CS 265 Computer Architecture Wei Lu, Ph.D., P.Eng. 1 Part 1: Data Representation Our goal: revisit and re-establish fundamental of mathematics for the computer architecture course Overview: what are bits

More information

Computer Architecture

Computer Architecture BASICS Hardware components Computer Architecture Computer Organization The von Neumann architecture Same storage device for both instructions and data Processor components Arithmetic Logic Unit Control

More information

Integer Representation Floating point Representation Other data types

Integer Representation Floating point Representation Other data types Chapter 2 Bits, Data Types & Operations Integer Representation Floating point Representation Other data types Why do Computers use Base 2? Base 10 Number Representation Natural representation for human

More information

CS Programming In C

CS Programming In C CS 24000 - Programming In C Week Two: Basic C Program Organization and Data Types Zhiyuan Li Department of Computer Science Purdue University, USA 2 int main() { } return 0; The Simplest C Program C programs

More information

Floating Point. CSE 351 Autumn Instructor: Justin Hsia

Floating Point. CSE 351 Autumn Instructor: Justin Hsia Floating Point CSE 351 Autumn 2017 Instructor: Justin Hsia Teaching Assistants: Lucas Wotton Michael Zhang Parker DeWilde Ryan Wong Sam Gehman Sam Wolfson Savanna Yee Vinny Palaniappan Administrivia Lab

More information

Data Representation Floating Point

Data Representation Floating Point Data Representation Floating Point CSCI 2400 / ECE 3217: Computer Architecture Instructor: David Ferry Slides adapted from Bryant & O Hallaron s slides via Jason Fritts Today: Floating Point Background:

More information

Beyond Base 10: Non-decimal Based Number Systems

Beyond Base 10: Non-decimal Based Number Systems Beyond Base : Non-decimal Based Number Systems What is the decimal based number system? How do other number systems work (binary, octal and hex) How to convert to and from nondecimal number systems to

More information

Chapter 1 Getting Started

Chapter 1 Getting Started Chapter 1 Getting Started The C# class Just like all object oriented programming languages, C# supports the concept of a class. A class is a little like a data structure in that it aggregates different

More information

Basic data types. Building blocks of computation

Basic data types. Building blocks of computation Basic data types Building blocks of computation Goals By the end of this lesson you will be able to: Understand the commonly used basic data types of C++ including Characters Integers Floating-point values

More information

Jin-Soo Kim Systems Software & Architecture Lab. Seoul National University. Integers. Spring 2019

Jin-Soo Kim Systems Software & Architecture Lab. Seoul National University. Integers. Spring 2019 Jin-Soo Kim (jinsoo.kim@snu.ac.kr) Systems Software & Architecture Lab. Seoul National University Integers Spring 2019 4190.308: Computer Architecture Spring 2019 Jin-Soo Kim (jinsoo.kim@snu.ac.kr) 2 A

More information

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

CS 61C: Great Ideas in Computer Architecture. (Brief) Review Lecture CS 61C: Great Ideas in Computer Architecture (Brief) Review Lecture Instructor: Justin Hsia 7/16/2013 Summer 2013 Lecture #13 1 Topic List So Far (1/2) Number Representation Signed/unsigned, Floating Point

More information

CSE 1320 INTERMEDIATE PROGRAMMING - OVERVIEW AND DATA TYPES

CSE 1320 INTERMEDIATE PROGRAMMING - OVERVIEW AND DATA TYPES CSE 1320 INTERMEDIATE PROGRAMMING - OVERVIEW AND DATA TYPES Mingon Kang The University of Texas at Arlington C History ANSI C, also known C89(ANSI X3.159-1989) and C90 (ISO/IEC 9899:1990) ANSI: American

More information

MACHINE LEVEL REPRESENTATION OF DATA

MACHINE LEVEL REPRESENTATION OF DATA MACHINE LEVEL REPRESENTATION OF DATA CHAPTER 2 1 Objectives Understand how integers and fractional numbers are represented in binary Explore the relationship between decimal number system and number systems

More information

CS356: Discussion #6 Assembly Procedures and Arrays. Marco Paolieri

CS356: Discussion #6 Assembly Procedures and Arrays. Marco Paolieri CS356: Discussion #6 Assembly Procedures and Arrays Marco Paolieri (paolieri@usc.edu) Procedures Functions are a key abstraction in software They break down a problem into subproblems. Reusable functionality:

More information

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

Number Systems for Computers. Outline of Introduction. Binary, Octal and Hexadecimal numbers. Issues for Binary Representation of Numbers Outline of Introduction Administrivia What is computer architecture? What do computers do? Representing high level things in binary Data objects: integers, decimals, characters, etc. Memory locations (We

More information

Princeton University. Computer Science 217: Introduction to Programming Systems. Data Types in C

Princeton University. Computer Science 217: Introduction to Programming Systems. Data Types in C Princeton University Computer Science 217: Introduction to Programming Systems Data Types in C 1 Goals of C Designers wanted C to: Support system programming Be low-level Be easy for people to handle But

More information

Computer Architecture /

Computer Architecture / Computer Architecture 02-201 / 02-601 The Conceptual Architecture of a Computer PC CPU register 0 register 1 register 2 registers hold small amounts of data for processing by the CPU Reading / writing

More information

Bits and Bytes. Why bits? Representing information as bits Binary/Hexadecimal Byte representations» numbers» characters and strings» Instructions

Bits and Bytes. Why bits? Representing information as bits Binary/Hexadecimal Byte representations» numbers» characters and strings» Instructions Bits and Bytes Topics Why bits? Representing information as bits Binary/Hexadecimal Byte representations» numbers» characters and strings» Instructions Bit-level manipulations Boolean algebra Expressing

More information

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

Systems I. Floating Point. Topics IEEE Floating Point Standard Rounding Floating Point Operations Mathematical properties Systems I Floating Point Topics IEEE Floating Point Standard Rounding Floating Point Operations Mathematical properties IEEE Floating Point IEEE Standard 754 Established in 1985 as uniform standard for

More information

COMP2611: Computer Organization. Data Representation

COMP2611: Computer Organization. Data Representation COMP2611: Computer Organization Comp2611 Fall 2015 2 1. Binary numbers and 2 s Complement Numbers 3 Bits: are the basis for binary number representation in digital computers What you will learn here: How

More information

Data Representation Floating Point

Data Representation Floating Point Data Representation Floating Point CSCI 2400 / ECE 3217: Computer Architecture Instructor: David Ferry Slides adapted from Bryant & O Hallaron s slides via Jason Fritts Today: Floating Point Background:

More information

Things to know about Numeric Computation

Things to know about Numeric Computation Things to know about Numeric Computation Classes of Numbers Countable Sets of Numbers: N: Natural Numbers {1, 2, 3, 4...}. Z: Integers (contains N) {..., -3, -2, -1, 0, 1, 2, 3,...} Q: Rational Numbers

More information

BASIC COMPUTER ORGANIZATION. Operating System Concepts 8 th Edition

BASIC COMPUTER ORGANIZATION. Operating System Concepts 8 th Edition BASIC COMPUTER ORGANIZATION Silberschatz, Galvin and Gagne 2009 Topics CPU Structure Registers Memory Hierarchy (L1/L2/L3/RAM) Machine Language Assembly Language Running Process 3.2 Silberschatz, Galvin

More information

CS 101: Computer Programming and Utilization

CS 101: Computer Programming and Utilization CS 101: Computer Programming and Utilization Jul-Nov 2017 Umesh Bellur (cs101@cse.iitb.ac.in) Lecture 3: Number Representa.ons Representing Numbers Digital Circuits can store and manipulate 0 s and 1 s.

More information

231 Spring Final Exam Name:

231 Spring Final Exam Name: 231 Spring 2010 -- Final Exam Name: No calculators. Matching. Indicate the letter of the best description. (1 pt. each) 1. b address 2. d object code 3. g condition code 4. i byte 5. k ASCII 6. m local

More information

CC411: Introduction To Microprocessors

CC411: Introduction To Microprocessors CC411: Introduction To Microprocessors OBJECTIVES this chapter enables the student to: Use number { base 2, base 10, or base 16 }. Add and subtract binary/hex numbers. Represent any binary number in 2

More information

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

Floating Point Puzzles. Lecture 3B Floating Point. IEEE Floating Point. Fractional Binary Numbers. Topics. IEEE Standard 754 Floating Point Puzzles Topics Lecture 3B Floating Point IEEE Floating Point Standard Rounding Floating Point Operations Mathematical properties For each of the following C expressions, either: Argue that

More information

Syllabus for Computer Science General Part I

Syllabus for Computer Science General Part I Distribution of Questions: Part I Q1. (Compulsory: 20 marks). Any ten questions to be answered out of fifteen questions, each carrying two marks (Group A 3 questions, Group B, Group C and Group D 4 questions

More information

The Programming Process Summer 2010 Margaret Reid-Miller

The Programming Process Summer 2010 Margaret Reid-Miller The Programming Process 15-110 Margaret Reid-Miller Hardware Components Central Processing Unit (CPU) Program control Arithmetic/logical operations Coordinates data movement between memory and registers

More information

Chapter 2. Data Representation in Computer Systems

Chapter 2. Data Representation in Computer Systems Chapter 2 Data Representation in Computer Systems Chapter 2 Objectives Understand the fundamentals of numerical data representation and manipulation in digital computers. Master the skill of converting

More information

Chapter 2. Instructions: Language of the Computer. Adapted by Paulo Lopes

Chapter 2. Instructions: Language of the Computer. Adapted by Paulo Lopes Chapter 2 Instructions: Language of the Computer Adapted by Paulo Lopes Instruction Set The repertoire of instructions of a computer Different computers have different instruction sets But with many aspects

More information

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

Administrivia. CMSC 216 Introduction to Computer Systems Lecture 24 Data Representation and Libraries. Representing characters DATA REPRESENTATION Administrivia CMSC 216 Introduction to Computer Systems Lecture 24 Data Representation and Libraries Jan Plane & Alan Sussman {jplane, als}@cs.umd.edu Project 6 due next Friday, 12/10 public tests posted

More information

231 Spring Final Exam Name:

231 Spring Final Exam Name: 231 Spring 2010 -- Final Exam Name: No calculators. Matching. Indicate the letter of the best description. (1 pt. each) 1. address 2. object code 3. condition code 4. byte 5. ASCII 6. local variable 7..global

More information

CHW 261: Logic Design

CHW 261: Logic Design CHW 261: Logic Design Instructors: Prof. Hala Zayed Dr. Ahmed Shalaby http://www.bu.edu.eg/staff/halazayed14 http://bu.edu.eg/staff/ahmedshalaby14# Slide 1 Slide 2 Slide 3 Digital Fundamentals CHAPTER

More information

Computer Architecture

Computer Architecture Computer components CPU - Central Processor Unit (e.g., G3, Pentium III, RISC) RAM - Random Access Memory (generally lost when power cycled) VRAM - Video RAM (amount sets screen size and color depth) ROM

More information

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

Floating Point Puzzles. Lecture 3B Floating Point. IEEE Floating Point. Fractional Binary Numbers. Topics. IEEE Standard 754 Floating Point Puzzles Topics Lecture 3B Floating Point IEEE Floating Point Standard Rounding Floating Point Operations Mathematical properties For each of the following C expressions, either: Argue that

More information

Bits, Words, and Integers

Bits, Words, and Integers Computer Science 52 Bits, Words, and Integers Spring Semester, 2017 In this document, we look at how bits are organized into meaningful data. In particular, we will see the details of how integers are

More information

Lecture 4 - Number Representations, DSK Hardware, Assembly Programming

Lecture 4 - Number Representations, DSK Hardware, Assembly Programming Lecture 4 - Number Representations, DSK Hardware, Assembly Programming James Barnes (James.Barnes@colostate.edu) Spring 2014 Colorado State University Dept of Electrical and Computer Engineering ECE423

More information

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

Floating Point (with contributions from Dr. Bin Ren, William & Mary Computer Science) Floating Point (with contributions from Dr. Bin Ren, William & Mary Computer Science) Floating Point Background: Fractional binary numbers IEEE floating point standard: Definition Example and properties

More information

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

Chapter 03: Computer Arithmetic. Lesson 09: Arithmetic using floating point numbers Chapter 03: Computer Arithmetic Lesson 09: Arithmetic using floating point numbers Objective To understand arithmetic operations in case of floating point numbers 2 Multiplication of Floating Point Numbers

More information

Contents. Preface. Introduction. Introduction to C Programming

Contents. Preface. Introduction. Introduction to C Programming c11fptoc.fm Page vii Saturday, March 23, 2013 4:15 PM Preface xv 1 Introduction 1 1.1 1.2 1.3 1.4 1.5 Introduction The C Programming Language C Standard Library C++ and Other C-Based Languages Typical

More information

CS 101, Mock Computer Architecture

CS 101, Mock Computer Architecture CS 101, Mock Computer Architecture Computer organization and architecture refers to the actual hardware used to construct the computer, and the way that the hardware operates both physically and logically

More information

Review for COSC 120 8/31/2017. Review for COSC 120 Computer Systems. Review for COSC 120 Computer Structure

Review for COSC 120 8/31/2017. Review for COSC 120 Computer Systems. Review for COSC 120 Computer Structure Computer Systems Computer System Computer Structure C++ Environment Imperative vs. object-oriented programming in C++ Input / Output Primitive data types Software Banking System Compiler Music Player Text

More information

3.5 Floating Point: Overview

3.5 Floating Point: Overview 3.5 Floating Point: Overview Floating point (FP) numbers Scientific notation Decimal scientific notation Binary scientific notation IEEE 754 FP Standard Floating point representation inside a computer

More information

ECE 250 / CS 250 Computer Architecture. C to Binary: Memory & Data Representations. Benjamin Lee

ECE 250 / CS 250 Computer Architecture. C to Binary: Memory & Data Representations. Benjamin Lee ECE 250 / CS 250 Computer Architecture C to Binary: Memory & Data Representations Benjamin Lee Slides based on those from Alvin Lebeck, Daniel Sorin, Andrew Hilton, Amir Roth, Gershon Kedem Administrivia

More information

Arithmetic and Bitwise Operations on Binary Data

Arithmetic and Bitwise Operations on Binary Data Arithmetic and Bitwise Operations on Binary Data CSCI 2400: Computer Architecture ECE 3217: Computer Architecture and Organization Instructor: David Ferry Slides adapted from Bryant & O Hallaron s slides

More information