Chapter 4: Computer Codes. In this chapter you will learn about:

Similar documents
MACHINE LEVEL REPRESENTATION OF DATA

Basic data types. Building blocks of computation

Binary Codes. Dr. Mudathir A. Fagiri

Number Systems. Dr. Tarek A. Tutunji Philadelphia University, Jordan

LOGIC DESIGN. Dr. Mahmoud Abo_elfetouh

Memory Addressing, Binary, and Hexadecimal Review

Number Systems Prof. Indranil Sen Gupta Dept. of Computer Science & Engg. Indian Institute of Technology Kharagpur Number Representation

BINARY SYSTEM. Binary system is used in digital systems because it is:

Digital Fundamentals

Review of Number Systems

Digital Fundamentals

Digital Computers and Machine Representation of Data

OBJECTIVES After reading this chapter, the student should be able to:

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

Excerpt from: Stephen H. Unger, The Essence of Logic Circuits, Second Ed., Wiley, 1997

Computer Organization

Binary. Hexadecimal BINARY CODED DECIMAL

IBM 370 Basic Data Types

Representing Characters, Strings and Text

Lecture (02) Operations on numbering systems

Digital Logic. The Binary System is a way of writing numbers using only the digits 0 and 1. This is the method used by the (digital) computer.

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

UNIT 7A Data Representation: Numbers and Text. Digital Data

Chapter 2 Number Systems and Codes Dr. Xu

CMPS 10 Introduction to Computer Science Lecture Notes

CHW 261: Logic Design

Electronic Data and Instructions

Chapter 11 : Computer Science. Information Representation. Class XI ( As per CBSE Board) New Syllabus

Five classic components

Homework 1 graded and returned in class today. Solutions posted online. Request regrades by next class period. Question 10 treated as extra credit

1.1. INTRODUCTION 1.2. NUMBER SYSTEMS

N.B. These pastpapers may rely on the knowledge gained from the previous chapters.

ELECTRICAL AND COMPUTER ENGINEERING DEPARTMENT, OAKLAND UNIVERSITY ECE-278: Digital Logic Design Fall Notes - Unit 4. hundreds.

ELECTRICAL AND COMPUTER ENGINEERING DEPARTMENT, OAKLAND UNIVERSITY ECE-2700: Digital Logic Design Winter Notes - Unit 4. hundreds.

DATA REPRESENTATION. By- Neha Tyagi PGT CS KV 5 Jaipur II Shift, Jaipur Region. Based on CBSE curriculum Class 11. Neha Tyagi, KV 5 Jaipur II Shift

Chapter 3: Number Systems and Codes. Textbook: Petruzella, Frank D., Programmable Logic Controllers. McGraw Hill Companies Inc.

Number System. Introduction. Decimal Numbers

Thus needs to be a consistent method of representing negative numbers in binary computer arithmetic operations.

Positional notation Ch Conversions between Decimal and Binary. /continued. Binary to Decimal

Computer Science 324 Computer Architecture Mount Holyoke College Fall Topic Notes: Bits and Bytes and Numbers

umber Systems bit nibble byte word binary decimal

UNIT 2 NUMBER SYSTEM AND PROGRAMMING LANGUAGES

Number codes nibble byte word double word

Chapter 7. Representing Information Digitally

Data Representation COE 301. Computer Organization Prof. Muhamed Mudawar

Chapter 2. Data Representation in Computer Systems

CHAPTER TWO. Data Representation ( M.MORRIS MANO COMPUTER SYSTEM ARCHITECTURE THIRD EDITION ) IN THIS CHAPTER

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

DIGITAL SYSTEM FUNDAMENTALS (ECE 421) DIGITAL ELECTRONICS FUNDAMENTAL (ECE 422) COURSE / CODE NUMBER SYSTEM

Lecture (01) Digital Systems and Binary Numbers By: Dr. Ahmed ElShafee

CHAPTER 2 Data Representation in Computer Systems

TOPICS. Other Number Systems. Other Number Systems 9/9/2017. Octal Hexadecimal Number conversion

Data Representation. DRAM uses a single capacitor to store and a transistor to select. SRAM typically uses 6 transistors.

CHAPTER 2 Data Representation in Computer Systems

DRAM uses a single capacitor to store and a transistor to select. SRAM typically uses 6 transistors.

Data Representation and Binary Arithmetic. Lecture 2

Number System (Different Ways To Say How Many) Fall 2016

(Refer Slide Time: 00:23)

M1 Computers and Data

Final Labs and Tutors

Chapter 2 Number System

CS & IT Conversions. Magnitude 10,000 1,

Introduction to Numbering Systems

Number representations

Integers. N = sum (b i * 2 i ) where b i = 0 or 1. This is called unsigned binary representation. i = 31. i = 0

Number Systems and Conversions UNIT 1 NUMBER SYSTEMS & CONVERSIONS. Number Systems (2/2) Number Systems (1/2) Iris Hui-Ru Jiang Spring 2010

Numeral Systems. -Numeral System -Positional systems -Decimal -Binary -Octal. Subjects:

a- As a special case, if there is only one symbol, no bits are required to specify it.

Computer Organization and Assembly Language. Lab Session 4

Number Systems Base r

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

Binary Systems and Codes

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

Level ISA3: Information Representation

Announcement. (CSC-3501) Lecture 3 (22 Jan 2008) Today, 1 st homework will be uploaded at our class website. Seung-Jong Park (Jay)

Digital Fundamentals. CHAPTER 2 Number Systems, Operations, and Codes

Programming Concepts and Skills. ASCII and other codes

CMPE223/CMSE222 Digital Logic Design. Positional representation

ECE 2020B Fundamentals of Digital Design Spring problems, 6 pages Exam Two Solutions 26 February 2014

Number Systems & Encoding

UTF and Turkish. İstinye University. Representing Text

Chapter 3 DATA REPRESENTATION

2. MACHINE REPRESENTATION OF TYPICAL ARITHMETIC DATA FORMATS (NATURAL AND INTEGER NUMBERS).

1.1 Information representation

Basic Definition INTEGER DATA. Unsigned Binary and Binary-Coded Decimal. BCD: Binary-Coded Decimal

Representing Characters and Text

LING 388: Computers and Language. Lecture 5

Informats. Informats in the CMS Environment. Considerations for Using Informats under CMS. EBCDIC and Character Data CHAPTER 15

Module -10. Encoder. Table of Contents

CS 31: Intro to Systems Binary Representation. Kevin Webb Swarthmore College January 27, 2015

NUMBER SYSTEMS AND CODES

Lecture (01) Introduction Number Systems and Conversion (1)

Dec Hex Bin ORG ; ZERO. Introduction To Computing

REPRESENTING INFORMATION:

DEPARTMENT OF ELECTRICAL AND COMPUTER ENGINEERING, THE UNIVERSITY OF NEW MEXICO ECE-238L: Computer Logic Design Fall 2013.

Chapter 4: Data Representations

DLD VIDYA SAGAR P. potharajuvidyasagar.wordpress.com. Vignana Bharathi Institute of Technology UNIT 1 DLD P VIDYA SAGAR

Lecture (03) Binary Codes Registers and Logic Gates

COMP2121: Microprocessors and Interfacing. Number Systems

Digital Logic Lecture 4 Binary Codes

Transcription:

Ref. Page Slide 1/30 Learning Objectives In this chapter you will learn about: Computer data Computer codes: representation of data in binary Most commonly used computer codes Collating sequence Ref. Page 36 Slide 2/30 1

Data Types Numeric Data consists of only numbers 0, 1, 2,, 9 Alphabetic Data consists of only the letters A, B, C,, Z, in both uppercase and lowercase, and blank character Alphanumeric Data is a string of symbols where a symbol may be one of the letters A, B, C,, Z, in either uppercase or lowercase, or one of the digits 0, 1, 2,, 9, or a special character, such as + - * /,. ( ) = etc. Ref. Page 36 Slide 3/30 Computer Codes Computer codes are used for internal representation of data in computers As computers use binary numbers for internal data representation, computer codes use binary coding schemes In binary coding, every symbol that appears in the data is represented by a group of bits The group of bits used to represent a symbol is called a byte (Continued on next slide) Ref. Page 36 Slide 4/30 2

Computer Codes (Continued from previous slide..) As most modern coding schemes use 8 bits to represent a symbol, the term byte is often used to mean a group of 8 bits Commonly used computer codes are BCD, EBCDIC, and ASCII Ref. Page 36 Slide 5/30 BCD BCD stands for Binary Coded Decimal It is one of the early computer codes It uses 6 bits to represent a symbol It can represent 64 (2 6 ) different characters Ref. Page 36 Slide 6/30 3

Coding of Alphabetic and Numeric Characters in BCD Char BCD Code Zone Digit Octal Char BCD Code Zone Digit Octal A B C D E F G H I J K L M 61 62 63 64 65 66 67 70 71 41 42 43 44 N O P Q R S T U V W X Y Z 45 46 47 50 51 22 23 24 25 26 27 30 31 (Continued on next slide) Ref. Page 37 Slide 7/30 Coding of Alphabetic and Numeric Characters in BCD (Continued from previous slide..) Character 1 2 3 4 5 6 7 8 9 0 BCD Code Zone Digit Octal Equivalent 02 03 04 05 06 07 12 Ref. Page 37 Slide 8/30 4

BCD Coding Scheme (Example 1) Example Show the binary digits used to record the word BASE in BCD Solution: B = 10 in BCD binary notation A = in BCD binary notation S = in BCD binary notation E = in BCD binary notation So the binary digits 10 B A S E will record the word BASE in BCD Ref. Page 38 Slide 9/30 BCD Coding Scheme (Example 2) Example Using octal notation, show BCD coding for the word DIGIT Solution: D = 64 in BCD octal notation I = 71 in BCD octal notation G = 67 in BCD octal notation I = 71 in BCD octal notation T = 23 in BCD octal notation Hence, BCD coding for the word DIGIT in octal notation will be 64 71 67 71 23 D I G I T Ref. Page 38 Slide /30 5

EBCDIC EBCDIC stands for Extended Binary Coded Decimal Interchange Code It uses 8 bits to represent a symbol It can represent 256 (2 8 ) different characters Ref. Page 38 Slide /30 Coding of Alphabetic and Numeric Characters in EBCDIC Char A B C D E F G EBCDIC Code Digit Zone 10 10 10 10 10 10 10 Hex C1 C2 C3 C4 C5 C6 C7 Char N O P Q R S T EBCDIC Code Digit Zone Hex D5 D6 D7 D8 D9 E2 E3 H I J K L M 10 10 C8 C9 D1 D2 D3 D4 U V W X Y Z E4 E5 E6 E7 E8 E9 (Continued on next slide) Ref. Page 39 Slide 12/30 6

Coding of Alphabetic and Numeric Characters in EBCDIC (Continued from previous slide..) Character 0 1 2 3 4 5 6 7 8 9 EBCDIC Code Digit Zone Hexadecima l Equivalent F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 Ref. Page 39 Slide 13/30 Zoned Decimal Numbers Zoned decimal numbers are used to represent numeric values (positive, negative, or unsigned) in EBCDIC A sign indicator (C for plus, D for minus, and F for unsigned) is used in the zone position of the rightmost digit Zones for all other digits remain as F, the zone value for numeric characters in EBCDIC In zoned format, there is only one digit per byte Ref. Page 39 Slide 14/30 7

Examples Zoned Decimal Numbers Numeric Value 345 +345-345 EBCDIC F3F4F5 F3F4C5 F3F4D5 Sign Indicator F for unsigned C for positive D for negative Ref. Page 40 Slide 15/30 Packed Decimal Numbers Packed decimal numbers are formed from zoned decimal numbers in the following manner: Step 1: The zone half and the digit half of the rightmost byte are reversed Step 2: All remaining zones are dropped out Packed decimal format requires fewer number of bytes than zoned decimal format for representing a number Numbers represented in packed decimal format can be used for arithmetic operations Ref. Page 39 Slide 16/30 8

Examples of Conversion of Zoned Decimal Numbers to Packed Decimal Format Numeric Value 345 +345-345 3456 EBCDIC F3F4F5 F3F4C5 F3F4D5 F3F4F5F6 Sign Indicator 345F 345C 345D 03456F Ref. Page 40 Slide 17/30 EBCDIC Coding Scheme Example Using binary notation, write EBCDIC coding for the word BIT. many bytes are required for this representation? How Solution: B = 10 in EBCDIC binary notation I = 10 in EBCDIC binary notation T = in EBCDIC binary notation Hence, EBCDIC coding for the word BIT in binary notation will be 10 B I T 3 bytes will be required for this representation because each letter requires 1 byte (or 8 bits) Ref. Page 40 Slide 18/30 9

ASCII ASCII stands for American Standard Code for Information Interchange. ASCII is of two types ASCII-7 and ASCII-8 ASCII-7 uses 7 bits to represent a symbol and can represent 128 (2 7 ) different characters ASCII-8 uses 8 bits to represent a symbol and can represent 256 (2 8 ) different characters First 128 characters in ASCII-7 and ASCII-8 are same Ref. Page 40 Slide 19/30 Coding of Numeric and Alphabetic Characters in ASCII Character 0 1 2 3 4 5 6 7 8 9 ASCII-7 / ASCII-8 Zone Digit Hexadecimal Equivalent 30 31 32 33 34 35 36 37 38 39 (Continued on next slide) Ref. Page 42 Slide 20/30

Coding of Numeric and Alphabetic Characters in ASCII (Continued from previous slide..) Character A B C D E F G H I J K L M ASCII-7 / ASCII-8 Zone Digit 10 Hexadecimal Equivalent 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D (Continued on next slide) Ref. Page 42 Slide 21/30 Coding of Numeric and Alphabetic Characters in ASCII (Continued from previous slide..) Character N O P Q R S T U V W X Y Z ASCII-7 / ASCII-8 Zone Digit Hexadecimal Equivalent 4E 4F 50 51 52 53 54 55 56 57 58 59 5A Ref. Page 42 Slide 22/30

ASCII-7 Coding Scheme Example Write binary coding for the word BOY in ASCII-7. How many bytes are required for this representation? Solution: B = 0 in ASCII-7 binary notation O = 1 in ASCII-7 binary notation Y = 1 in ASCII-7 binary notation Hence, binary coding for the word BOY in ASCII-7 will be 0 1 1 B O Y Since each character in ASCII-7 requires one byte for its representation and there are 3 characters in the word BOY, 3 bytes will be required for this representation Ref. Page 43 Slide 23/30 ASCII-8 Coding Scheme Example Write binary coding for the word SKY in ASCII-8. How many bytes are required for this representation? Solution: S = in ASCII-8 binary notation K = in ASCII-8 binary notation Y = in ASCII-8 binary notation Hence, binary coding for the word SKY in ASCII-8 will be S K Y Since each character in ASCII-8 requires one byte for its representation and there are 3 characters in the word SKY, 3 bytes will be required for this representation Ref. Page 43 Slide 24/30 12

Unicode Why Unicode: No single encoding system supports all languages Different encoding systems conflict Unicode features: Provides a consistent way of encoding multilingual plain text Defines codes for characters used in all major languages of the world Defines codes for special characters, mathematical symbols, technical symbols, and diacritics Ref. Page 44 Slide 25/30 Unicode Unicode features (continued): Capacity to encode as many as a million characters Assigns each character a unique numeric value and name Reserves a part of the code space for private use Affords simplicity and consistency of ASCII, even corresponding characters have same code Specifies an algorithm for the presentation of text with bi-directional behavior Encoding Forms UTF-8, UTF-16, UTF-32 Ref. Page 44 Slide 26/30 13

Collating Sequence Collating sequence defines the assigned ordering among the characters used by a computer Collating sequence may vary, depending on the type of computer code used by a particular computer In most computers, collating sequences follow the following rules: 1. Letters are considered in alphabetic order (A < B < C < Z) 2. Digits are considered in numeric order (0 < 1 < 2 < 9) Ref. Page 46 Slide 27/30 Sorting in EBCDIC Example Suppose a computer uses EBCDIC as its internal representation of characters. In which order will this computer sort the strings 23, A1, 1A? Solution: In EBCDIC, numeric characters are treated to be greater than alphabetic characters. Hence, in the said computer, numeric characters will be placed after alphabetic characters and the given string will be treated as: A1 < 1A < 23 Therefore, the sorted sequence will be: A1, 1A, 23. Ref. Page 46 Slide 28/30 14

Sorting in ASCII Example Suppose a computer uses ASCII for its internal representation of characters. In which order will this computer sort the strings 23, A1, 1A, a2, 2a, aa, and Aa? Solution: In ASCII, numeric characters are treated to be less than alphabetic characters. Hence, in the said computer, numeric characters will be placed before alphabetic characters and the given string will be treated as: 1A < 23 < 2a < A1 < Aa < a2 < aa Therefore, the sorted sequence will be: 1A, 23, 2a, A1, Aa, a2, and aa Ref. Page 47 Slide 29/30 Key Words/Phrases Alphabetic data Alphanumeric data American Standard Code for Information Interchange (ASCII) Binary Coded Decimal (BCD) code Byte Collating sequence Computer codes Control characters Extended Binary-Coded Decimal Interchange Code (EBCDIC) Hexadecimal equivalent Numeric data Octal equivalent Packed decimal numbers Unicode Zoned decimal numbers Ref. Page 47 Slide 30/30 15