Lecture # 5 Data Representation. Today Questions: From notes/reading/life? Prepare for Quiz # 1 (Multiple Choice) 1.Introduce: How do Computers store.

Slides:



Advertisements
Similar presentations
Primitive Data Types There are a number of common objects we encounter and are treated specially by almost any programming language These are called basic.
Advertisements

Lecturer: Omid Jafarinezhad Sharif University of Technology Department of Computer Engineering 1 Fundamental of Programming (C) Lecture 2 Number Systems.
Review Binary –Each digit place is a power of 2 –Any two state phenomenon can encode a binary number –The number of bits (digits) required directly relates.
Basic C Programming Data Types and Arithmetic Operations 01/30/15.
Chapter 1 Data Storage. 2 Chapter 1: Data Storage 1.1 Bits and Their Storage 1.2 Main Memory 1.3 Mass Storage 1.4 Representing Information as Bit Patterns.
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Adrian Ilie COMP 14 Introduction to Programming Adrian Ilie June 27, 2005.
Chapter 2 Data Types, Declarations, and Displays
Chapter 4: The Building Blocks: Binary Numbers, Boolean Logic, and Gates Invitation to Computer Science, C++ Version, Fourth Edition.
Representation and Conversion of Numeric Types 4 We have seen multiple data types that C provides for numbers: int and double 4 What differences are there.
66 CHAPTER SYSTEM UNIT. © 2005 The McGraw-Hill Companies, Inc. All Rights Reserved. 1-2 Announcement: Major Exam 01 Thursday, 17th March, 2005 Building.
Data Storage. SIGN AND MAGNITUDE Storing and representing numbers.
Binary Representation and Computer Arithmetic
(2.1) Fundamentals  Terms for magnitudes – logarithms and logarithmic graphs  Digital representations – Binary numbers – Text – Analog information 
Computers Organization & Assembly Language
Binary Codes Computers and other digital systems "work" with binary numbers. I/P & O/P is usually done using decimal numbers, alphabetics, special symbols.
Georgia Institute of Technology Introduction to Java, and DrJava Barb Ericson Georgia Institute of Technology Aug 2005.
IT253: Computer Organization
Information and Programs. Foundations of Computing Information –Binary numbers –Integers and Floating Point –Booleans (True, False) –Characters –Variables.
What is a computer? A computer is a device that:
Islamic University Of Gaza, Nael Aburas Data Storage Introduction to computer, 2nd semester, 2010/2011 Mr.Nael Aburas
Chapter 1 Data Storage © 2007 Pearson Addison-Wesley. All rights reserved.
Operators & Identifiers The Data Elements. Arithmetic Operators exponentiation multiplication division ( real ) division ( integer quotient ) division.
CISC1100: Binary Numbers Fall 2014, Dr. Zhang 1. Numeral System 2  A way for expressing numbers, using symbols in a consistent manner.  " 11 " can be.
Data Representation, Number Systems and Base Conversions
Binary System Presented by Mr. Wilhelmi Internal Representation of Data Input Input  Data that is put into the computer for processing Data Data  The.
Data Representation (in computer system). Data Representation How do computers represent data? b The computers are digital Recognize.
Data Storage © 2007 Pearson Addison-Wesley. All rights reserved.
Java Programming, Second Edition Chapter Two Using Data Within a Program.
CEC 220 Digital Circuit Design Binary Codes
Operators & Identifiers The Data Elements. Arithmetic Operators exponentiation multiplication division ( real ) division ( integer quotient ) division.
Data Representation.
Number Representation Lecture Topics How are numeric data items actually stored in computer memory? How much space (memory locations) is.
CEC 220 Digital Circuit Design Binary Codes Mon, Aug 31 CEC 220 Digital Circuit Design Slide 1 of 14.
Hardware Information Created by Nasih 1. Hardware  The physical components of a computer system, including any peripheral equipment such as printers,
Operators A binary operator combines two values to get one result: x OP y where OP is any binary operators such as +, -, *, /, ==, !=, >, &&, or even =.
The Hexadecimal System is base 16. It is a shorthand method for representing the 8-bit bytes that are stored in the computer system. This system was chosen.
09/06/ Data Representation ASCII, Binary Denary Conversion, Integer & Boolean data types.
Number Systems. The position of each digit in a weighted number system is assigned a weight based on the base or radix of the system. The radix of decimal.
1 CE 454 Computer Architecture Lecture 4 Ahmed Ezzat The Digital Logic, Ch-3.1.
Nat 4/5 Computing Science Lesson 1: Binary
Topic: Binary Encoding – Part 2
Computer Science 210 Computer Organization
Topic: Binary Encoding – Part 1
Computer basics.
3 – Boolean Logic and Logic Gates 4 – Binary Numbers
Invitation to Computer Science, C++ Version, Fourth Edition
Week 2 - Wednesday CS 121.
Data Representation Binary Numbers Binary Addition
CSCI 198: Lecture 4: Data Representation
BINARY CODE.
Chapter 4 – Fundamental Data Types
ITEC113 Algorithms and Programming Techniques
CSCI 161: Lecture 4: Data Representation
EPSII 59:006 Spring 2004.
Invitation to Computer Science, Java Version, Third Edition
Chapter 1 Data Storage.
The Building Blocks: Binary Numbers, Boolean Logic, and Gates
Computer Science 210 Computer Organization
Number Systems Lecture 2.
Plan Attendance Files Posted on Campus Cruiser Homework Reminder
Storing Negative Integers
How Computers Store Data
Chapter 3 DataStorage Foundations of Computer Science ã Cengage Learning.
Data Representation and Organization
Data Types and Expressions
The Data Element.
COMS 161 Introduction to Computing
The Data Element.
Presentation transcript:

Lecture # 5 Data Representation

Today Questions: From notes/reading/life? Prepare for Quiz # 1 (Multiple Choice) 1.Introduce: How do Computers store data? 2.Explain: Data Types: Binary numbers, Integers, Floating Point, Booleans, Characters, Variables 3.Demo: Do some binary conversions: on board 4.Practice: Do some binary examples: in head, on keyboard 5.Evaluate: We will share and evaluate your conversions 6.Re-practice: Turn the crank on binary as you go to sleep Understand Data Types, Storage ReviewPrograms

Today Questions: From notes/reading/life? Prepare for Quiz # 1 (Multiple Choice) 1.Introduce: How do Computers store data? 2.Explain: Data Types: Binary numbers, Integers, Floating Point, Booleans, Characters, Variables 3.Demo: Do some binary conversions: on board 4.Practice: Do some binary examples: in head, on keyboard 5.Evaluate: We will share and evaluate your conversions 6.Re-practice: Turn the crank on binary as you go to sleep Understand Data Types, Storage ReviewPrograms

Today Questions: From notes/reading/life? Prepare for Quiz # 1 (Multiple Choice) 1.Introduce: How do Computers store data? 2.Explain: Data Types: Binary numbers, Integers, Floating Point, Booleans, Characters, Variables 3.Demo: Do some binary conversions: on board 4.Practice: Do some binary examples: in head, on keyboard 5.Evaluate: We will share and evaluate your conversions 6.Re-practice: Turn the crank on binary as you go to sleep Understand Data Types, Storage ReviewPrograms

Data Representation If we want to compare, sort and organize data, we need to have a way to represent it in a computer – electronically. Even the characters you are now reading, as words, must be able to be represented and encoded electronically and numerically. The following slides will explain how we represent and encode data in a computer, and how we manipulate and reason about it in a computer program.

How to Represent Data in a Computer

Foundations of Computing Information Data Types –Binary numbers –Integers and Floating Point –Booleans (True, False) –Characters –Variables Programs –Expressions –Assignment –Sequences

There are 10 kinds of people in the world – those who understand binary and those who do not.

Information Data Types  Binary numbers Integers and Floating Point Booleans (True, False) Characters Variables

Decimal Numbers Each digit is a power of ten = 5 * *1 + 4 * * * * * * * *10,000

Binary Numbers Each Digit is a power of two = 0 * 2 0 (1)+ 1 * 2 1 (2)+ 1 * 2 2 (4)+ 0 * 2 3 (8)+ 1 * 2 4 (16) = 22

Binary Numbers Each Digit is a power of two = = 93 1 * 2 0 (1) + 0 * 2 1 (2) + 1 * 2 2 (4) + 1 * 2 3 (8) + 1 * 2 4 (16) + 0 * 2 5 (32) + 1 * 2 6 (64)

Why Binary? Any physical phenomenon that has two states can be used to store a binary number 11010= 26

Magnetism Magnetic Material Read/Write Head = 43

Voltage = 37

Holes in Paper Light = 1 Dark = = 42 Photo Sensor Light

Binary Students Male = 0 Female = 1

Why Binary? Any physical phenomenon that has two states can be used to store a binary number Each binary digit is called a BIT – is a 4 bit number – is an 8 bit number An 8 bit number is called a BYTE

Size of a Binary Number How many different numbers can you store in 2 bits? How many can you store in 8 bits? In general, 2 (number of bits) numbers can be stored How many in 10 bits? –1024 = 1K How many in 20 bits? –1,048,576 = 1Meg

Information Binary numbers  Integers and Floating Point Booleans (True, False) Characters Variables

Integers

Size of an Integer How many bits required for the number 17? 5 bits How many bits for the number 1023? 10 bits

Integer Expressions * means multiply / means divide 2*4+3 = 11 2*(4+3) = 14 (7+9)/2 = 8

Floating point numbers Numbers with decimal points

Floating point numbers Numbers with decimal points 1.23 = 0.123e = e =-0.232e-2 Stored differently (sign + fraction + exponent)

Information Binary numbers Integers and Floating Point  Booleans (True, False) Characters Variables

Booleans 1 = true 0 = false

Boolean Expressions (7>3) is true ((2+4)<6) is false –Note Arithmetic Expression in Boolean Expression > Greater than < less than <= less than or equal >= greater than or equal == equal != not equal 7<=6 is false 6!=5 is true

Information Binary numbers Integers and Floating Point Booleans (True, False)  Characters Variables

ASCII Code for Characters Every character is defined to have an 8 bit (1 byte) number What is special about the order of the numbers? Type ‘ g ’ Store 103

ASCII Code for Characters A numeric character is different from its ASCII number

ASCII Code for Characters

What about Chinese, Sanscrit, Hebrew, Cyrillic, etc ??

UNICODE rather than ASCII 2 Bytes per character –Twice as much space –65,536 possible characters (2^16)

Expressions with characters ‘ A ’ + 2 = ‘ C ’ ‘ g ’ - ‘ d ’ = 3 ‘ F ’ + 32 = ‘ f ’ ‘ A ’ < ‘ D ’ is true ‘ % ’ >= ‘ + ’ is false

Information Binary numbers Integers and Floating Point Booleans (True, False) Characters  Variables

Variable A named place to store a value –George = 32 –Size = 17 –Weight = 120

Today Questions: From notes/reading/life? Prepare for Quiz # 1 (Multiple Choice) 1.Introduce: How do Computers store data? 2.Explain: Data Types: Binary numbers, Integers, Floating Point, Booleans, Characters, Variables 3.Demo: Do some binary conversions: on board 4.Practice: Do some binary examples: in head, on keyboard 5.Evaluate: We will share and evaluate your conversions 6.Re-practice: Turn the crank on binary as you go to sleep Understand Data Types, Storage ReviewPrograms

Binary Exercise Binary devices include: The binary number = what in decimal? How many bits are required to store the decimal number 256?

Review Binary devices include: paper and magnetic tape, disks, transistors The binary number = what in decimal? 45 How many bits are required to store the decimal number 256? 9 bits

Today Questions: From notes/reading/life? Prepare for Quiz # 1 (Multiple Choice) 1.Introduce: How do Computers store data? 2.Explain: Data Types: Binary numbers, Integers, Floating Point, Booleans, Characters, Variables 3.Demo: Do some binary conversions: on board 4.Practice: Do some binary examples: in head, on keyboard 5.Evaluate: We will share and evaluate your conversions 6.Re-practice: Turn the crank on binary as you go to sleep Understand Data Types, Storage ReviewPrograms

Programs Computer Programs make use of a these data types to perform a given task Standard arithmetic operations can be applied to manipulate the input data types and output a result