Representing Data. Representing data u The basic unit of memory is the bit  A transistor that can hold either high or low voltage  Conceptually, a tiny.

Slides:



Advertisements
Similar presentations
Number Systems and Codes
Advertisements

Information Representation
© 2004, Robert K. Moniot Binary and Hex How to count like a computer.
Data Representation COE 202 Digital Logic Design Dr. Aiman El-Maleh
Representing Numbers: Integers
DATA REPRESENTATION CONVERSION.
Digital Fundamentals Floyd Chapter 2 Tenth Edition
Representing Information as Bit Patterns Lecture 4 CSCI 1405, CSCI 1301 Introduction to Computer Science Fall 2009.
Introduction to Programming with Java, for Beginners
Data Representation in Computers
Introduction to Information Technology
COE 202: Digital Logic Design Number Systems Part 1
Number Systems & Logic Gates Day 1
Chapter 1 Number Systems and Codes 1. Outline 1. NUMBER SYSTEMS AND CODES 2. DIGITAL ELECTRONIC SIGNALS AND SWITCHES 3. BASIC LOGIC GATES 4. PROGRAMMABLE.
Number Systems - Part I CS 215 Lecture # 5.
©Brooks/Cole, 2003 Chapter 2 Data Representation.
Chapter 2 Data Representation. Define data types. Visualize how data are stored inside a computer. Understand the differences between text, numbers, images,
(2.1) Fundamentals  Terms for magnitudes – logarithms and logarithmic graphs  Digital representations – Binary numbers – Text – Analog information 
ACOE1611 Data Representation and Numbering Systems Dr. Costas Kyriacou and Dr. Konstantinos Tatas.
Numeral Systems Subjects: Numeral System Positional systems Decimal
Chapter 3 Representing Numbers and Text in Binary Information Technology in Theory By Pelin Aksoy and Laura DeNardis.
Representing text Each of different symbol on the text (alphabet letter) is assigned a unique bit patterns the text is then representing as.
C Programming Lecture 3. The Three Stages of Compiling a Program b The preprocessor is invoked The source code is modified b The compiler itself is invoked.
CSC212 – Computer Organization and Design
Numbering Systems CS208.
IT-101 Section 001 Lecture #3 Introduction to Information Technology.
1 Number SystemsLecture 8. 2 BINARY (BASE 2) numbers.
Computer Math CPS120: Data Representation. Representing Data The computer knows the type of data stored in a particular location from the context in which.
Foundations of Computer Science Computing …it is all about Data Representation, Storage, Processing, and Communication of Data 10/4/20151CS 112 – Foundations.
EX_01.1/46 Numeric Systems. EX_01.2/46 Overview Numeric systems – general, Binary numbers, Octal numbers, Hexadecimal system, Data units, ASCII code,
Binary Code.
Lec 3: Data Representation Computer Organization & Assembly Language Programming.
1 Problem Solving using computers Data.. Representation & storage Representation of Numeric data The Binary System.
Integer Representation for People Computer Organization and Assembly Language: Module 3.
Number systems, Operations, and Codes
Number Systems and Codes
The Hexadecimal Number System and Memory Addressing ISAT 121.
Chapter 19 Number Systems. Irvine, Kip R. Assembly Language for Intel-Based Computers, Translating Languages English: Display the sum of A times.
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.
EET 250 Number systems. Introduction to Number Systems While we live in a world where the decimal number is predominant in our lives, computers and digital.
EEL 3801C EEL 3801 Part I Computing Basics. EEL 3801C Data Representation Digital computers are binary in nature. They operate only on 0’s and 1’s. Everything.
THE BINARY SYSTEM.
Data Representation, Number Systems and Base Conversions
AEEE2031 Data Representation and Numbering Systems.
DATA REPRESENTATION CHAPTER DATA TYPES Different types of data (Fig. 2.1) The computer industry uses the term “MULTIMEDIA” to define information.
Number Representation (Part 1) Computer Architecture (Fall 2006)
Data Representation. What is data? Data is information that has been translated into a form that is more convenient to process As information take different.
MECH1500 Chapter 3.
Computer Science I Storing data. Binary numbers. Classwork/homework: Catch up. Do analysis of image types.
Data Representation. How is data stored on a computer? Registers, main memory, etc. consists of grids of transistors Transistors are in one of two states,
ASCII AND EBCDIC CODES By : madam aisha.
Characters and Strings
Fall’ 2014 Lesson - 1 Number System & Program Design CSE 101.
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.
Digital logic COMP214  Lecture 2 Dr. Sarah M.Eljack Chapter 1 1.
Fall’ 2014 Number System CSE Number System How Computers Represent Data Binary Numbers The Binary Number System Bits and Bytes Text Codes Binary.
Number Systems Decimal (Base 10) –10 digits (0,1,2,3,4,5,6,7,8,9) Binary (Base 2) –2 digits (0,1) Digits are often called bits (binary digits) Hexadecimal.
Some basic concepts underlying computer archi­tecture
Number Systems.
Number Systems and Codes
Lec 3: Data Representation
Information Support and Services
EPSII 59:006 Spring 2004.
Number Systems.
Number Systems and Codes
Ch2: Data Representation
Chapter 2 Data Representation.
UNIT – 3 & 4. Data Representation and Internal
Networks & I/O Devices.
Presentation transcript:

Representing Data

Representing data u The basic unit of memory is the bit  A transistor that can hold either high or low voltage  Conceptually, a tiny container that can hold 1 or 0  All data is represented using 1’s and 0’s u How are integers represented? u How are colors represented? u How are strings represented?

Representing numbers

Weighted Positional Notation u Use the position of the symbol to indicate the value u By assigning each position the appropriate power of the base, we can get a unique representation of numbers in that base Decimal System (Base 10) Given a sequence of n digits d 0,d 1,…,d n-1 d n-1.10 n-1 + … + d d

Weighted Positional Notation u In general, given a sequence of n digits s 0,s 1,…,s n-1 and a base b, s n-1.b n-1 + … + s 1.b 1 + s 0.b 0 yields a unique integer N u s 0 is the least significant digit u s n-1 is the most significant digit u The most significant symbol can not be zero

Weighted Positional Notation u Any positive integer value can be used as the base for a weighted positional notation u For bases less than or equal to 10, a subset of the ten decimal digits can be used  binary (base 2)  octal (base 8) u For bases more than 10, new symbols will have to be introduced  hexadecimal (base16)  A=10, B=11, C=12, D=13, E=14, F=15

Weighted Positional Notation u A subscript is used to indicate the base of the number in typeset  A number without a subscript is assumed to be base 10  Not an option while programming u In VB, hexadecimal representation begins with &H  &H10 (= decimal 16) u So the following instructions are identical  form.backcolor = &H13  form.backcolor = 19

Representations in Different Bases binary hexdecimalbinaryhexdecimal A B C D E F15

Binary and Hexadecimal u Discriminating between two voltage levels is currently cheaper in digital circuitry than three or more, thus binary is the representation for computers u It is much easier for humans to work with hexadecimal representations  Long strings of 1’s and 0’s are hard to remember u Binary to hexadecimal conversion is more direct than binary to decimal conversion  Reason: 16 is a power of 2

Conversion to Decimal Given a sequence of base-r digits s n-1... s 1 s 0 convert the sequence into a decimal number N using: N = s n-1 *b n-1 + … + s 1 *b 1 + s 0 *b 0

Conversion to Decimal Convert to decimal N = 1* * * * * *2 0 = 38 Convert 3b2 16 to decimal N = 3* * *16 0 = 946 Convert to decimal N = 3* * *8 0 = = 248

A Binary Exercise u The binary number is identical to 139 base 10 u In the decimal, the number 139 can be written is interpreted as: 1 X 100 = X 10 = 30 9 X 1 = + 9 Total 139 u In binary, the same procedure yields: 1 x 128 = x 64 = 0 0 x 32 = 0 0 x 16 = 0 1 x 8 = 8 0 x 4 = 0 1 x 2 = 2 1 x 1 = + 1 Total = 139

A Hexadecimal Exercise Binary  Decimal: x 128 = x 64 = 0 0 x 32 = 0 0 x 16 = 0 1 x 8 = 8 0 x 4 = 0 1 x 2 = 2 1 x 1 = + 1 Total = 139 Hexadecimal  Decimal: 8B 8 x 16 = 128 B or 11 x 1 = +11 Total = 139

Converting Binary to Hexadecimal u Converting binary to hexadecimal is a simple exercise in pattern recognition  Break the binary number into groups of 4 bits, starting from the right  If necessary, pad the leftmost group with 0's until it is also 4 bits in length  Replace each 4 bit grouping with a single hexadecimal character determined by the chart

Representations in Different Bases binary hexdecimalbinaryhexdecimal A B C D E F15

Binary-Hex Conversion Example u Convert the binary number to hexadecimal A 9 5 3

Representing Colors and Strings

Specifying Visual Basic Colors u Two ways:  By Color name  Ex: “vbRed”, “vbGreen”, “vbBlue”  Provides basic colors  Must know the precise names allowed  By Hexadecimal color value  Ex: “&H00FF3A”  Allows up to 16.7 million possibilities!

Color Theory u All colors are a combination of three primary colors  Red  Green  Blue u Specify intensity of each primary color to create a unique color

Combining primary colors 256 Intensities 256 Intensities 256 Intensities Total possibilities = or approximately 16.7 million colors!

Why 256 Intensities? u Computers operate on Base 2 u 1 bit can be either 0 or 1  0 is off, 1 is on u 1 byte consists of 8 bits  Ex:  The possibilities are 2 8 or u A byte is the smallest addressable unit of computer storage

Using hexadecimal for colors u Each primary color intensity is expressed as two hexadecimal digits u Possibilities are u Ex: Convert 221 to Hexadecimal  221/16 = 13 Remainder 12  13 = D in Hexadecimal  12 = C in Hexadecimal  221 = &HDC  In the properties window, VB displays all color codes with 8 hexadecimal digits &H000000DC

Expressing hexadecimal colors u Sample Color Value:  &H00DC0F4A Prefix indicating a hexadecimal number The first byte codes the blue saturation The second byte codes the green saturation The third byte codes the red saturation

Color Intensity u 00 is the lowest intensity u FF is the highest intensity u What color is &H000000? u What color is &HFFFFFF?

Representing Text ASCII (American National Standards Institute ANSI) American Standard Code for Information Interchange ASCII code is an 8bit code for character representation. For example the code for H is , for e is So the message “Hello.” can be coded as

Representing Text ASCII table (starting from #32)

ASCII Table u The ASCII table is appendix A of the text u You can find many examples of the ASCII table of characters online, for example