Lecture 2: Representing Numbers CS 2011 Fall 2014, Dr. Rozier.

Slides:



Advertisements
Similar presentations
CS/COE0447 Computer Organization & Assembly Language
Advertisements

© 2004, Robert K. Moniot Binary and Hex How to count like a computer.
University of Washington CSE351 Announcements:  HW0, having fun?  Use discussion boards!  Sign up for mailing list  If you enrolled recently,
CSCE 212 Computer Organization Lecture 2 Data Representation.
Bits and Bytes 4/2/2008 Topics Physics, transistors, Moore’s law Why bits? Representing information as bits Binary/Hexadecimal Byte representations »numbers.
Bits and Bytes CS 213 Aug. 27, 1998 Topics Why bits? Representing information as bits –Binary/Hexadecimal –Byte representations »numbers »characters and.
Bits and Bytes January 17, 2002 Topics Why bits? Representing information as bits –Binary/Hexadecimal –Byte representations »numbers »characters and strings.
Nyhoff, ADTs, Data Structures and Problem Solving with C++, Second Edition, © 2005 Pearson Education, Inc. All rights reserved Introduction.
Bits and Bytes Topics Physics, transistors, Moore’s law Why bits? Representing information as bits Binary/Hexadecimal Byte representations »numbers »characters.
Nyhoff, ADTs, Data Structures and Problem Solving with C++, Second Edition, © 2005 Pearson Education, Inc. All rights reserved Introduction.
ICS 2005 Instructor: Peter A. Dinda TA: Bin Lin Recitation 2.
Bits and Bytes January 15, 2004 Topics Why bits? Representing information as bits Binary/Hexadecimal Byte representations »numbers »characters and strings.
Bits and Bytes Topics Why bits? Representing information as bits Binary/Hexadecimal Byte representations »numbers »characters and strings »Instructions.
Microprocessor Systems Design I
Fabián E. Bustamante, Spring 2007 Bits and Bytes Today Why bits? Binary/hexadecimal Byte representations Boolean algebra Expressing in C.
COMP201 Computer Systems Number Representation. Number Representation Introduction Number Systems Integer Representations Examples  Englander Chapter.
© Janice Regan, CMPT 128, Jan CMPT 128: Introduction to Computing Science for Engineering Students Integer Data representation Addition and Multiplication.
Summer 2014 Chapter 1: Basic Concepts. Irvine, Kip R. Assembly Language for Intel-Based Computers 6/e, Chapter Overview Welcome to Assembly Language.
IT253: Computer Organization
Number Systems Spring Semester 2013Programming and Data Structure1.
Carnegie Mellon 1 Bits, Bytes, and Integers Lecture, Jan. 24, 2013 These slides are from website which accompanies the book “Computer.
Automata, Computability, and Complexity Lecture 1 Section 0.1 Wed, Aug 22, 2007.
Implementation of a Stored Program Computer ITCS 3181 Logic and Computer Systems 2014 B. Wilkinson Slides2.ppt Modification date: Oct 16,
Lecture 2: Basic Instructions CS 2011 Fall 2014, Dr. Rozier.
IT253: Computer Organization Lecture 3: Memory and Bit Operations Tonga Institute of Higher Education.
CS 270: Computer Organization Bits, Bytes, and Integers
Number Systems 2.1 Information Storage Why not decimal numbers in computers ? Difficult to store ENIAC (1 st electronic computer) used 10 vacuum tubes.
Bits and Bytes Spring, 2015 Topics Why bits? Representing information as bits Binary / Hexadecimal Byte representations »Numbers »Characters and strings.
Bits and Bytes Topics Representing information as bits Bit-level manipulations Boolean algebra Expressing in C.
Lecture 3: Computation and Representation CS 2011 Fall 2014, Dr. Rozier.
Carnegie Mellon 1 Bits, Bytes, and Integers : Introduction to Computer Systems 3 rd Lectures, May 27th, 2014 Instructors: Greg Kesden.
Bits and Bytes Topics Why bits? Tell me Representing information as bits Binary/Hexadecimal Byte representations »numbers »characters and strings »Instructions.
Bits, Bytes, and Integers Topics Representing information as bits Bit-level manipulations Boolean algebra Expressing in C Representations of Integers Basic.
These notes were originally developed for CpSc 210 (C version) by Dr. Mike Westall in the Department of Computer Science at Clemson.
Bits and Bytes September 2, 2004 Topics Why bits? Representing information as bits Binary / Hexadecimal Byte representations »Numbers »Characters and strings.
– 1 – Number Systems Number of symbols = base of the system Most intuitive -- base 10 (decimal system) counting on fingertips symbols
ACOE2511 Assembly Language for the 80X86/Pentium Intel Microprocessors Lecturer: Dr. Konstantinos Tatas.
Info stored in computer (memory) Numbers All in binaray – can be converted to octal, hex Characters ASCII – 1-byte/char Unicode – 2-byte/char Unicode-table.com/en.
Carnegie Mellon 1 This week: Bits, Bytes, and Integers Representing information as bits Bit-level manipulations Integers  Representation: unsigned and.
Number Representation Lecture Topics How are numeric data items actually stored in computer memory? How much space (memory locations) is.
Lecture 4: Load/Store Architectures CS 2011 Fall 2014, Dr. Rozier.
Bits and Bytes Topics Why bits? Representing information as bits
Carnegie Mellon Bits, Bytes, and Integers (1-2) /18-243: Introduction to Computer Systems 2 nd Lecture, 19 May 2011 Instructors: Gregory Kesden.
 Data Type is a basic classification which identifies different types of data.  Data Types helps in: › Determining the possible values of a variable.
1 University of Washington Today’s topics Just enough EE to be dangerous Memory and its bits, bytes, and integers Representing information as bits Bit-level.
Lecture 2 Two’s Complement Proofs Topics Two’s complement January 11, 2016 CSCE 212H Computer Architecture.
Number Systems and Representations Binary Representation Binary Representation Signed numbers Signed numbers Very small and very big numbers Very small.
Carnegie Mellon 1 Saint Louis University Data Representation in Memory CSCI 2400 / ECE 3217: Computer Architecture Instructor: David Ferry Slides adapted.
Number Systems & Binary Arithmetic
Instructors: Greg Kesden
The Machine Model Memory
Big-Endians Little-Endians and Bi-Endians
EPSII 59:006 Spring 2004.
Data Structures Mohammed Thajeel To the second year students
Announcements VM on the website! Speedometer!
Bases and Representations, Memory, Pointers, Arrays, For-Loops
Introduction to Abstract Data Types
Bits and Bytes Topics Representing information as bits
Comp Org & Assembly Lang
Bits and Bytes Topics Representing information as bits
Bits and Bytes Topics Representing information as bits
Bits and Bytes Topics Representing information as bits
“The Class That Gives CMU Its Zip!”
Bits and Bytes Topics Representing information as bits
A Closer Look at Instruction Set Architectures Chapter 5
Comp Org & Assembly Lang
Comp Org & Assembly Lang
“The Class That Gives CMU Its Zip!”
“The Class That Gives CMU Its Zip!”
Dr. Clincy Professor of CS
Presentation transcript:

Lecture 2: Representing Numbers CS 2011 Fall 2014, Dr. Rozier

LADIES AND TIGERS

The Lady and the Tiger Two doors containing either Ladies or Tigers

The Lady and the Tiger You will be shown two doors, to two rooms. – Each could contain either a lady or a tiger… – It could be that both rooms contain a lady, or that both rooms contain a tiger! You will need to reason carefully and logically to survive! Each question, pick a door, or decide not to open a door. – You score one point for picking a lady, or for refusing to pick if both doors contain tigers. – Three points available for your homework/projects grade today – If you answer wrong, you may write a short paper describing what you did wrong, and how to find the right answer, due next class.

The Lady and the Tiger Form up into groups On a sheet of paper, list the first and last names of each student in the group, and pick a team name – Discuss your answers, and record them – Each group will then give their answers to the class

The Lady and the Tiger Q1 One of these is true… In this room, there is a lady, and in the other room there is a tiger. The other is false… In one of these rooms there is a lady, and in one of these rooms there is a tiger.

The Lady and the Tiger Q1 One of these is true…The other is false…

The Lady and the Tiger Q2 Either both signs are false… At least one of these rooms contains a lady Or both are true… A tiger is in the other room…

The Lady and the Tiger Q2 Either both signs are false…Or both are true…

The Lady and the Tiger Q3 Either both signs are false… Either a tiger is in this room, or a lady is in the other room. Or both are true… An lady is in the other room.

The Lady and the Tiger Q3 Either both signs are false…Or both are true…

What does this have to do with CS?

CS and CE What are the disciplines? – Computer Engineering? – Computer Science?

What it isn’t "What would we like our children- the general public of the future—to learn about computer science in schools? We need to do away with the myth that computer science is about computers. Computer science is no more about computers than astronomy is about telescopes, biology is about microscopes or chemistry is about beakers and test tubes. Science is not about tools, it is about how we use them and what we find out when we do." -- Ian Parberry

What it isn’t A confusion of even longer standing came from the fact that the unprepared included the electronic engineers that were supposed to design, build, and maintain the machines. The job was actually beyond the electronic technology of the day, and, as a result, the question of how to get and keep the physical equipment more or less in working condition became in the early days the all-overriding concern. As a result, the topic became —primarily in the USA— prematurely known as "computer science" —which, actually is like referring to surgery as "knife science"— and it was firmly implanted in people's minds that computing science is about machines and their peripheral equipment. -- Edsger Dijkstra

What it really is Computer science is the study of the theoretical foundations of information and computation and of practical techniques for their implementation and application in computer systems. Computer scientists invent algorithmic processes that create, describe, and transform information and formulate suitable abstractions to model complex systems. Computer engineering is the process of analyzing, designing, and integrating the hardware and software systems needed for information processing or computation. Computer engineers are saddled with the difficult tasks of modeling, designing, and analyzing cyberphysical systems which solve interdisciplinary problems in a wide variety of domains.

REPRESENTING NUMBERS

How can we represent numbers in a computer? What limitations do we face? What requirements do we have?

Networking and Communication What if we encode the signal into pulses? Detect if the value is above or below some threshold, and decide it represents a 1, or a 0. Strings of 1’s and 0’s can be interpreted as a number.

Some simple things we can represent with 1’s and 0’s True or false… – 1 – true – 0 – false – We already were doing this with pure signals.

Some simple things we can represent with 1’s and 0’s Integers Examples – – – – – 10 – – – 147

Unsigned Binary Integers Given an n-bit number Range: 0 to +2 n – 1 Example = 0 + … + 1× ×2 2 +1×2 1 +1×2 0 = 0 + … = Using 32 bits 0 to +4,294,967,295

Binary and Hexadecimal Because binary numbers are rather unwieldy, programmers prefer to use a more compact way to represent them. Historically, octal (base 8) and hexadecimal (base 16, or hex) have been used. – Octal has the advantage that it uses only familiar digits, but it groups digits by threes, which is inconvenient for word sizes that are multiples of 4. So it is seldom used nowadays. – Hexadecimal works nicely for bytes and for word sizes that are multiples of 4, but requires the introduction of 6 new digits. Conversion between binary and decimal is slow and is preferably avoided if there is no need. Octal and hex allow immediate conversion to and from binary.

Hexadecimal Base 16 – Compact representation of bit strings – 4 bits per hex digit c d a1010e b1011f1111 Example: eca

COMPUTING SYSTEMS

Computing Introduction to Computing Systems What is a computing system?

Computing Introduction to Computing Systems What is a computing system? What does it mean to compute something?

Chomsky’s Hierarchy What does Noam Chomsky have to do with computation?

Chomsky’s Hierarchy What does Noam Chomsky have to do with computation? What do languages have to do with computing?

Chomsky’s Hierarchy

Finite Automata

Pushdown Automata

Turing Machine

Turing Equivalence What does it take to create a Turing Machine? What does this say about computing systems?

Bits, Bytes, and Ints

Binary Representations 0.0V 0.5V 2.8V 3.3V 010

Encoding Byte Values Byte = 8 bits – Binary to – Decimal: 0 10 to – Hexadecimal to FF 16 Base 16 number representation Use characters ‘0’ to ‘9’ and ‘A’ to ‘F’ Write FA1D37B 16 in C as – 0xFA1D37B – 0xfa1d37b A B C D E F Hex Decimal Binary

Byte-Oriented Memory Organization Programs Refer to Virtual Addresses – Conceptually very large array of bytes – Actually implemented with hierarchy of different memory types – System provides address space private to particular “process” Program being executed Program can clobber its own data, but not that of others Compiler + Run-Time System Control Allocation – Where different program objects should be stored – All allocation within single virtual address space 000 FFF

Machine Words Machine Has “Word Size” – Nominal size of integer-valued data Including addresses – Most current machines use 32 bits (4 bytes) words Limits addresses to 4GB Becoming too small for memory-intensive applications – High-end systems use 64 bits (8 bytes) words Potential address space ≈ 1.8 X bytes x86-64 machines support 48-bit addresses: 256 Terabytes – Machines support multiple data formats Fractions or multiples of word size Always integral number of bytes

Word-Oriented Memory Organization Addresses Specify Byte Locations – Address of first byte in word – Addresses of successive words differ by 4 (32-bit) or 8 (64-bit) bit Words BytesAddr bit Words Addr = ?? Addr = ?? Addr = ?? Addr = ?? Addr = ?? Addr = ??

Data Representations C Data TypeTypical 32-bitIntel IA32x86-64 char111 short222 int444 long float444 double888 long double810/1210/16 pointer448

Byte Ordering How should bytes within a multi-byte word be ordered in memory? Conventions – Big Endian: Sun, PPC Mac, Internet Least significant byte has highest address – Little Endian: x86 Least significant byte has lowest address

Byte Ordering Example Big Endian – Least significant byte has highest address Little Endian – Least significant byte has lowest address Example – Variable x has 4-byte representation 0x – Address given by &x is 0x100 0x1000x1010x1020x x1000x1010x1020x Big Endian Little Endian

AddressInstruction CodeAssembly Rendition :5b pop %ebx :81 c3 ab add $0x12ab,%ebx c:83 bb cmpl $0x0,0x28(%ebx) Reading Byte-Reversed Listings Disassembly – Text representation of binary machine code – Generated by program that reads the machine code Example Fragment Deciphering Numbers – Value: 0x12ab – Pad to 32 bits: 0x000012ab – Split into bytes: ab – Reverse: ab