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

Similar documents
Computer Organization

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

Digital Fundamentals

CHW 261: Logic Design

World Inside a Computer is Binary

SE311: Design of Digital Systems

Binary Codes. Dr. Mudathir A. Fagiri

Lecture (02) Operations on numbering systems

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

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

Introduction to Computer Science (I1100) Data Storage

MACHINE LEVEL REPRESENTATION OF DATA

Data Representation and Binary Arithmetic. Lecture 2

Lecture (03) Binary Codes Registers and Logic Gates

M1 Computers and Data

3 Data Storage 3.1. Foundations of Computer Science Cengage Learning

The Gray Code. Script

CHAPTER 2 - DIGITAL DATA REPRESENTATION AND NUMBERING SYSTEMS

DIGITAL SYSTEM DESIGN

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

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

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

Digital Fundamentals

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

Chapter 1. Digital Systems and Binary Numbers

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.

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

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

Data Representation 1

Chapter 4: Data Representations

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

Data Storage. Slides derived from those available on the web site of the book: Computer Science: An Overview, 11 th Edition, by J.

Numbering systems. Dr Abu Arqoub

Final Labs and Tutors

Representing Information. Bit Juggling. - Representing information using bits - Number representations. - Some other bits - Chapters 1 and 2.3,2.

Review of Number Systems

Chapter 1. Data Storage Pearson Addison-Wesley. All rights reserved

Bits and Bit Patterns

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

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

Chapter 2. Data Representation in Computer Systems

Chapter 2 Bits, Data Types, and Operations

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

Digital codes. Resources and methods for learning about these subjects (list a few here, in preparation for your research):

Slide Set 1. for ENEL 339 Fall 2014 Lecture Section 02. Steve Norman, PhD, PEng

Module -10. Encoder. Table of Contents

Digital Fundamentals

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

Chapter 3 DATA REPRESENTATION

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

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

Five classic components

Objectives. Connecting with Computer Science 2

Korea University of Technology and Education

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

Inf2C - Computer Systems Lecture 2 Data Representation

LING 388: Computers and Language. Lecture 5


Number System. Introduction. Decimal Numbers

Digital Systems and Binary Numbers

Number codes nibble byte word double word

Data Representation COE 301. Computer Organization Prof. Muhamed Mudawar

CPSC 301: Computing in the Life Sciences Lecture Notes 16: Data Representation

CS & IT Conversions. Magnitude 10,000 1,

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

Digital Logic Lecture 4 Binary Codes

Slide Set 1. for ENEL 353 Fall Steve Norman, PhD, PEng. Electrical & Computer Engineering Schulich School of Engineering University of Calgary

Binary Systems and Codes

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

SISTEMI EMBEDDED. Basic Concepts about Computers. Federico Baronti Last version:

EE 109 Unit 2. Analog vs. Digital. Analog vs. Digital. Binary Representation Systems ANALOG VS. DIGITAL

EE 109 Unit 3. Analog vs. Digital. Analog vs. Digital. Binary Representation Systems ANALOG VS. DIGITAL

D I G I T A L C I R C U I T S E E

1. Which of the following Boolean operations produces the output 1 for the fewest number of input patterns?

Unit 3. Analog vs. Digital. Analog vs. Digital ANALOG VS. DIGITAL. Binary Representation

Module 3: Representing Values in a Computer

Number Systems CHAPTER Positional Number Systems

The Building Blocks: Binary Numbers, Boolean Logic, and Gates. Purpose of Chapter. External Representation of Information.

EE 109 Unit 2. Binary Representation Systems

Chapter 3: Arithmetic for Computers

Positional Number System

Basic data types. Building blocks of computation

Topic Notes: Bits and Bytes and Numbers

Chapter 10 Binary Arithmetics

COMP2611: Computer Organization. Data Representation

Digital Systems and Binary Numbers

DATA REPRESENTATION. Data Types. Complements. Fixed Point Representations. Floating Point Representations. Other Binary Codes. Error Detection Codes

Moodle WILLINGDON COLLEGE SANGLI. ELECTRONICS (B. Sc.-I) Introduction to Number System

Chapter 1 Review of Number Systems

Groups of two-state devices are used to represent data in a computer. In general, we say the states are either: high/low, on/off, 1/0,...

Chapter 2 Data Representations

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

Chapter 2 Number Systems and Codes Dr. Xu

1.1. INTRODUCTION 1.2. NUMBER SYSTEMS

Digital Systems and Binary Numbers

Data Representation Type of Data Representation Integers Bits Unsigned 2 s Comp Excess 7 Excess 8

SET DEFINITION 1 elements members

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

Data Representation and Networking

Data Representations & Arithmetic Operations

Transcription:

Codes A single bit is useful if exactly two answers to a question are possible. Examples include the result of a coin toss (heads or tails), Most situations in life are more complicated. This chapter concerns ways in which complex objects can be represented not by a single bit, but by arrays of bits. It is convenient to focus on a very simple model of a system, shown in Figure 2.1, in which the input is one of a predetermined set of objects, or symbols, the identity of the particular symbol chosen is encoded in an array of bits, these bits are transmitted through space or time, and then are decoded at a later time or in a different place to determine which symbol was originally chosen. Some objects for which codes may be needed include: Letters: BCD, EBCDIC, ASCII, Unicode, Morse Code Integers: Binary, Gray, 2 s complement Numbers: Floating-Point Proteins: Genetic Code Telephones: NANP, International codes Hosts: Ethernet, IP Addresses, Domain names Images: TIFF, GIF, and JPEG Audio: MP3 Video: MPEG 1

Symbol Space Size The first question to address is the number of symbols that need to be encoded. This is called the symbol space size. We will consider symbol spaces of different sizes: 1, 2, Integral power of 2, Finite, Infinite Countable, Infinite Uncountable. a- As a special case, if there is only one symbol, no bits are required to specify it. b- If the number of symbols is 2, then the selection can be encoded in a single bit. c- If the number of possible symbols is 4, 8, 16, 32, 64, or another integral power of 2, then the selection may be coded in the number of bits equal to the logarithm, base 2, of the symbol space size. Thus 5 bits can encode the selection of one student in a class of 32. d- If the number of symbols is finite but not an integral power of 2, then the number of bits that would work is the next higher integral power of 2 can be used to encode the selection, but there will be some unused bit patterns. Examples include the 10 digits, the six faces of a cubic die, the 13 denominations of a playing card, and the 26 letters of the English alphabet. In each case, there is spare capacity (6 unused patterns in the 4-bit representation of digits, 2 unused patterns in the 3-bit representation of a die, etc.) e - If the number of symbols is infinite but countable then a bit string of a given length can only denote a finite number of items from this infinite set. Thus, a 4-bit code for non-negative integers might designate integers from 0 through 15, but would not be able to handle integers outside this range. f- If the number of symbols is infinite and uncountable (such as the value of a physical quantity like voltage) then some technique of discretization must be used to replace possible values by a finite number of selected values that are approximately the same. For example, if the numbers between 0 and 1 were the symbols and if 2 bits were available for the coded representation, one approach might be to approximate all numbers between 0 and 0.25 by the number 0.125, all numbers between 0.25 and 0.5 by 0.375, and so 2

on. Whether such an approximation is adequate depends on how the decoded data is used. Binary Coded Decimal (BCD) A common way to represent the digits 0-9 is by the ten four-bit patterns shown in Table 2.1. There are six bit patterns (for example 1010) that are not used, and the question is what to do with them. Here are a few ideas that come to mind. The unused patterns might be mapped into legal values. For example, the unused patterns might all be converted to 9, under the theory that they represent 10, 11, 12, 13, 14, or 15, and the closest digit is 9. Or they might be decoded as 2, 3, 4, 5, 6, or 7, by setting the initial bit to 0, under the theory that the first bit might have gotten corrupted. ASCII The most commonly used code for text characters, ASCII (American Standard Code for Information Interchange, described in Section 2.5) reserves 33 of its 128 codes explicitly for control, and only 95 for characters. These 95 include the 26 upper-case and 26 lower-case letters of the English alphabet, the 10 digits, space, and 32 punctuation marks. 3

Detail: Integer Codes There are many ways to represent integers as bit patterns. All suffer from an inability to represent arbitrarily large integers in a fixed number of bits. A computation which produces an out-of-range result is said to overflow. The most commonly used representations are binary code for unsigned integers (e.g., memory addresses), 2 s complement for signed integers (e.g., ordinary arithmetic), and binary gray code for instruments measuring changing quantities. The following table gives five examples of 4-bit integer codes. The MSB (most significant bit) is on the left and the LSB (least significant bit) on the right 4

Binary Code This code is for nonnegative integers. For code of length n, the 2 n patterns represent integers 0 through 2 n -1. The LSB (least significant bit) is 0 for even and 1 for odd integers. Binary Gray Code This code is for nonnegative integers. For code of length n, the 2 n patterns represent integers 0 through 2 n -1. The two bit patterns of adjacent integers differ in exactly one bit. This property makes the code useful for sensors where the integer being encoded might change while a measurement is in progress. 2 s Complement This code is for integers, both positive and negative. For a code of length n, the 2 n patterns represent integers - 2 n-1 through 2 n-1-1. The LSB (least significant bit) is 0 for even and 1 for odd integers. Where they overlap, this code is the same as binary code. This code is widely used. Sign/Magnitude This code is for integers, both positive and negative. For code of length n, the 2 n patterns represent integers - (2 n-1-1) through 2 n 1-1. The MSB (most significant bit) is 0 for positive and 1 for negative integers; the other bits carry the magnitude. Where they overlap, this code is the same as binary code. While conceptually simple. 1 s Complement This code is for integers, both positive and negative. For code of length n, the 2 n patterns represent integers - (2 n-1-1) through 2 n-1-1. The MSB is 0 for positive integers; negative integers are formed by complementing each bit of the corresponding positive integer. Where they overlap, this code is the same as binary code. 5