CSC255-702/703 CTI/DePaul1 CSC-255 Lecture 3 Text and Numerical Storage (Chapter 1 from Brookshear) Modified by Ufuk Verun from Jim Janossy © 2002, DePaul.

Slides:



Advertisements
Similar presentations
ICS312 Set 2 Representation of Numbers and Characters.
Advertisements

HEXADECIMAL NUMBERS Code
The Binary Numbering Systems
Lecture - 2 Number systems and computer data formats
1 CSE1301 Computer Programming Lecture 29: Number Representation (Part 1)
Chapter 1.7 Storing Fractions. Excess Notation, continued… In this notation, "m" indicates the total number of bits. For us (working with 8 bits), it.
Digital Fundamentals Floyd Chapter 2 Tenth Edition
CSC /703 CTI/DePaul1 CSC-255 Lecture 4 Negative Numbers, Images, Parity (Brookshear Chapter 1, pages 46-72) Modified by Ufuk Verun from Jim Janossy.
Representing Information as Bit Patterns
Representing Information as Bit Patterns Lecture 4 CSCI 1405, CSCI 1301 Introduction to Computer Science Fall 2009.
Chapter Chapter Goals Know the different types of numbers Describe positional notation.
Data Representation in Computers
S. Barua – CPSC 240 CHAPTER 2 BITS, DATA TYPES, & OPERATIONS Topics to be covered are Number systems.
IT-101 Section 001 Lecture #4 Introduction to Information Technology.
Data Storage. SIGN AND MAGNITUDE Storing and representing numbers.
Number Systems Computer Science 210 Computer Organization.
Binary Number Systems.
Data Representation in Computers
(2.1) Fundamentals  Terms for magnitudes – logarithms and logarithmic graphs  Digital representations – Binary numbers – Text – Analog information 
© 2009 Pearson Education, Upper Saddle River, NJ All Rights ReservedFloyd, Digital Fundamentals, 10 th ed Digital Fundamentals Tenth Edition Floyd.
Simple Data Type Representation and conversion of numbers
Abstraction – Number Systems and Data Representation.
Lecture 5.
Representing text Each of different symbol on the text (alphabet letter) is assigned a unique bit patterns the text is then representing as.
1 Digital Technology and Computer Fundamentals Chapter 1 Data Representation and Numbering Systems.
Computer Math CPS120: Data Representation. Representing Data The computer knows the type of data stored in a particular location from the context in which.
Binary Arithmetic & Data representation
EX_01.1/46 Numeric Systems. EX_01.2/46 Overview Numeric systems – general, Binary numbers, Octal numbers, Hexadecimal system, Data units, ASCII code,
Data Representation.
Number Systems Spring Semester 2013Programming and Data Structure1.
ICS312 Set 1 Representation of Numbers and Characters.
Lecture 1 Binary Representation Topics Terminology Base 10, Hex, binary Fractions Base-r to decimal Unsigned Integers Signed magnitude Two’s complement.
Information Representation. Digital Hardware Systems Digital Systems Digital vs. Analog Waveforms Analog: values vary over a broad range continuously.
Data Representation Dr. Ahmed El-Bialy Dr. Sahar Fawzy.
Lecture 5. Topics Sec 1.4 Representing Information as Bit Patterns Representing Text Representing Text Representing Numeric Values Representing Numeric.
Chapter 2 Binary Values and Number Systems. 2 2 Natural Numbers Zero and any number obtained by repeatedly adding one to it. Examples: 100, 0, 45645,
Number systems, Operations, and Codes
Operators & Identifiers The Data Elements. Arithmetic Operators exponentiation multiplication division ( real ) division ( integer quotient ) division.
Chapter 1 Data Storage © 2007 Pearson Addison-Wesley. All rights reserved.
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.
1 Data Representation Characters, Integers and Real Numbers Binary Number System Octal Number System Hexadecimal Number System Powered by DeSiaMore.
1 Representation of Data within the Computer Oct., 1999(Revised 2001 Oct)
Computer Math CPS120: Lecture 3. Binary computers have storage units called binary digits or bits: Low Voltage = 0 High Voltage = 1 all bits have 0 or.
Data Representation, Number Systems and Base Conversions
Computer Math CPS120 Introduction to Computer Science Lecture 4.
CDP ECE Spring 2000 ECE 291 Spring 2000 Lecture 2: Number Systems & x86 Instructions Constantine D. Polychronopoulos Professor, ECE Office: 463.
Agenda Character representation Numerical Conversions ASCII EBCDIC
Operators & Identifiers The Data Elements. Arithmetic Operators exponentiation multiplication division ( real ) division ( integer quotient ) division.
Digital Fundamentals Tenth Edition Floyd Chapter 2 © 2008 Pearson Education.
Chapter 1 Representing Data in a Computer. 1.1 Binary and Hexadecimal Numbers.
Lecture 2: 8/29/2002CS149D Fall CS149D Elements of Computer Science Ayman Abdel-Hamid Department of Computer Science Old Dominion University Lecture.
Nguyen Le CS147.  2.4 Signed Integer Representation  – Signed Magnitude  – Complement Systems  – Unsigned Versus Signed Numbers.
CS 125 Lecture 3 Martin van Bommel. Overflow In 16-bit two’s complement, what happens if we add =
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.
Binary Values. Numbers Natural Numbers Zero and any number obtained by repeatedly adding one to it. Examples: 100, 0, 45645, 32 Negative Numbers.
Lecture Coding Schemes. Representing Data English language uses 26 symbols to represent an idea Different sets of bit patterns have been designed to represent.
Some basic concepts underlying computer archi­tecture
Programming and Data Structure
NUMBER SYSTEMS.
Arithmetic Shifts and Character Representation
Number Representation
CHAPTER 1 : INTRODUCTION
Chapter 3 Data Representation
Numbering System TODAY AND TOMORROW 11th Edition
Information Representation
Dr. Clincy Professor of CS
Presenting information as bit patterns
Abstraction – Number Systems and Data Representation
Presentation transcript:

CSC /703 CTI/DePaul1 CSC-255 Lecture 3 Text and Numerical Storage (Chapter 1 from Brookshear) Modified by Ufuk Verun from Jim Janossy © 2002, DePaul University CTI – Chicago and Brookshear © 2003 Pearson Education, Inc.

CSC /703 CTI/DePaul2 Resources This PowerPoint presentation is available for download at ides/Lecture_03.ppt ides/Lecture_03.ppt Textbook: Chapter 1 Print slides at 6 slides/page, avoid waste! Exams are based on slide content, homework and assigned readings

CSC /703 CTI/DePaul3 Text Printable characters A, a, B, b, etc. Each different character is assigned a unique 8-bit pattern See the ASCII chart on page 499, Appendix A ASCII: American Standard Code for Information Interchange More recent codings use more bits to store more symbols and characters Unicode for Java, 16 bits per character

CSC /703 CTI/DePaul4 ASCII Developed in 1968 originally as a 7-bit code 7 bits can define 128 patterns, 2 7 =128 Extended to 8 bits, 2 8 =256 patterns Most common code in use EBCDIC is analogous IBM mainframe code, 8-bit, different assignment of codes to characters

CSC /703 CTI/DePaul5 ASCII Example Text “Hello.” coded in ASCII:

CSC /703 CTI/DePaul6 Unicode Developed in 1990’s as a 16-bit code Defines 65,536 patterns, 2 16 Implemented in Java Replaces earlier schemes to support non-English characters (such as Chinese and Japanese alphabets) First 128 characters are same as ASCII

CSC /703 CTI/DePaul7 Exercise: ASCII Practice What is “ABCabc” in ASCII? CharHexBits A B C a b c

CSC /703 CTI/DePaul8 Exercise: More ASCII Practice What is “01234” (“ means characters) in ASCII? CharHexBits

CSC /703 CTI/DePaul9 ASCII Text Facts Numbers sort before letters Uppercase letters (ABC) sort before lowercase letters (abc) Numbers represented as 8-bit values are inefficient for storage and arithmetic (12,345 takes 5 x 8 = 40 bits, but binary could store it in fewer bits -– 14 bits) All numbers (0 through 9) start with same bits: 0011

CSC /703 CTI/DePaul10 Packed Decimal All numbers (0..9) start with same bits 0011 With proper encoding/decoding, there is no need to store the first 4 bits for ASCII number storage Store only the last (unique) 4 bits of each digit, since first 4 bits for numbers are always the same (0011) Takes about half the storage space Where is the sign (+/-) stored?

CSC /703 CTI/DePaul11 Exercise: Encoding a Number into Packed Decimal What is “1,234” in ASCII? CharHexBits First 4 bits (0011) are the same for all decimal numbers (0 through 9) Only the low-order 4 bits are stored

CSC /703 CTI/DePaul12 Encoding into Packed Decimal… What is 1,234 in ASCII? CharHexBits Answer:

CSC /703 CTI/DePaul13 Encoding into Packed Decimal… What is 1,234 in ASCII? CharHexBits Answer: Now packed into 2 bytes!

CSC /703 CTI/DePaul14 Decoding Packed Decimal Question: What does represent? Someone has to tell you that the bytes contain a number that was stored in packed decimal You have to decode, then interpret it

CSC /703 CTI/DePaul15 Decoding Packed Decimal Decoding area is created Number: bytes, with leading 0011 generated in each

CSC /703 CTI/DePaul16 Decoding Packed Decimal Decoding area is loaded Number: bytes, with leading 0011 generated in each

CSC /703 CTI/DePaul17 Decoding Packed Decimal Decoding area is loaded Number: bytes, with leading 0011 generated in each

CSC /703 CTI/DePaul18 Decoding Packed Decimal Decoding area is loaded Number: bytes, with leading 0011 generated in each

CSC /703 CTI/DePaul19 Decoding Packed Decimal Decoding area is loaded Number: bytes, with leading 0011 generated in each

CSC /703 CTI/DePaul20 Decoding Packed Decimal Decoding area is interpreted Number:

CSC /703 CTI/DePaul21 Alternative Number Storages ASCII text: 8-bit “characters” Packed decimal: 4 bits per digit + sign Binary system: base 2 number system Pure binary, positive integers Two’s complement, signed values Excess notation Floating point: sign-exponent-mantissa

CSC /703 CTI/DePaul22 Binary System Base 2 number systems Pure binary, positive integers Two’s complement, signed values Excess notation All use bits differently than ASCII Nothing in the bits says whether they are binary coding or ASCII

CSC /703 CTI/DePaul23 Number Base Basics The “base” of a number system is defined by how many different digit symbols it uses Decimal is base 10: 0,1,2,3,4,5,6,7,8,9 Binary is base 2: 0,1 Octal is base 8: 0,1,2,3,4,5,6,7 Hex is base 16: 0 thru 9, A,B,C,D,E,F

CSC /703 CTI/DePaul24 Number Base Basics … The “value” of each column in a multi- digit number is determined by the number base it is expressed in Example: What is the decimal value of 1101 in decimal, binary, octal, hex?

CSC /703 CTI/DePaul25 Number Base 10 - Decimal You figure how much each column is worth, starting from the rightmost column: ’s 10’s 1’s x x x base 2 base 1 base 0 Base=10 (decimal)

CSC /703 CTI/DePaul ’s 10’s 1’s 1 01 Number Base 10 - Decimal x100 x10 x x1 0x10 1x100

CSC /703 CTI/DePaul ’s 2’s 1’s 1 01 Number Base 2 - Binary x4 x2 x x1 0x2 1x4

CSC /703 CTI/DePaul ’s 8’s 1’s 1 01 Number Base 8 - Octal x64 x8 x x1 0x8 1x64

CSC /703 CTI/DePaul ’s 16’s 1’s 1 01 Number Base 16 - Hexadecimal x256 x16 x x1 0x16 1x256

CSC /703 CTI/DePaul30 Converting from Base 10 to Other Number Bases Convert decimal 1,234 to binary - how? Convert decimal 1,234 to hex - how? Algorithm: 1. Divide number by the new number base 2. Record remainder as low order digit 3. Replace number with division result (quotient) 4. If quotient is not 0, go back to step 1 and repeat

CSC /703 CTI/DePaul31 Example: Converting Decimal 1,234 to Binary Low-order digit High-order digit quotientremainder 1234 / 2= / 2 = / 2 = / 2 = / 2 = / 2 = / 2 =91 9 / 2 =41 4 / 2 =20 2 / 2 =10 1 / 2=01

CSC /703 CTI/DePaul32 Example: Converting Decimal 1,234 to Hex 1234 / 16= / 16 =413=D 4 / 16=04 Low-order digit High-order digit quotientremainder 4D2

CSC /703 CTI/DePaul33 Facts about Binary Numbers Pure binary system stores positive integers only 8-bit number = 0 to 255 (2 8 ) 16-bit number = 0 to 65,535 (2 16 ) 32-bit number = 0 to 4,294,967,295 (2 32 ) But no matter how many bits are used, there is always some number too large to be represented

CSC /703 CTI/DePaul34 Binary Addition Binary addition facts Used as carry

CSC /703 CTI/DePaul35 Binary Addition Addition is as with decimal numbers decimalbinary

CSC /703 CTI/DePaul36 Binary Fractions Radix point is like decimal point Each column to the right of radix point is worth ½ of column to its left

CSC /703 CTI/DePaul37 Binary Fractions

CSC /703 CTI/DePaul38 Addition of Binary Fractions Just like normal binary numbers, add from rightmost to leftmost, use carry ½ ¼ 1/81/ = 2 + ¼ + 1 / 8 = = 4 + ½ + ¼ = 4.75 = / 8 =

CSC /703 CTI/DePaul39 Exercise: Addition of Binary Fractions ½¼ 1/81/8 124 = decimal ? ?? 1 /