umber Systems bit nibble byte word binary decimal

Similar documents
Chapter 2 Number Systems and Codes Dr. Xu

CMPS 10 Introduction to Computer Science Lecture Notes

Digital Fundamentals

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

Octal & Hexadecimal Number Systems. Digital Electronics

Review of Number Systems

MACHINE LEVEL REPRESENTATION OF DATA

Chapter 3 DATA REPRESENTATION

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

Beyond Base 10: Non-decimal Based Number Systems

Objectives. Connecting with Computer Science 2

Introduction to Numbering Systems

Digital Systems COE 202. Digital Logic Design. Dr. Muhamed Mudawar King Fahd University of Petroleum and Minerals

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

Number representations

Logic and Computer Design Fundamentals. Chapter 1 Digital Computers and Information

Memory Addressing, Binary, and Hexadecimal Review

COE 202- Digital Logic. Number Systems II. Dr. Abdulaziz Y. Barnawi COE Department KFUPM. January 23, Abdulaziz Barnawi. COE 202 Logic Design

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

Beyond Base 10: Non-decimal Based Number Systems

CHW 261: Logic Design

1.1. INTRODUCTION 1.2. NUMBER SYSTEMS

Digital Logic Lecture 2 Number Systems

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

Digital Fundamentals

plc numbers Encoded values; BCD and ASCII Error detection; parity, gray code and checksums

CHAPTER 2 Data Representation in Computer Systems

CHAPTER 2 Data Representation in Computer Systems

Positional Number System

Lecture 2: Number Systems

CC411: Introduction To Microprocessors

Level ISA3: Information Representation

Using sticks to count was a great idea for its time. And using symbols instead of real sticks was much better.

DIGITAL SYSTEM DESIGN

Dec Hex Bin ORG ; ZERO. Introduction To Computing

NUMBER SYSTEMS AND CODES

Microprocessors I MICROCOMPUTERS AND MICROPROCESSORS

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

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

Topic Notes: Bits and Bytes and 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.

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

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

1.1 Information representation

Review of Data Representation & Binary Operations Dhananjai M. Rao CSA Department Miami University

The Gray Code. Script

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

NUMBER SYSTEMS AND CODES

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

Binary Systems and Codes

LOGIC DESIGN. Dr. Mahmoud Abo_elfetouh

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

Topic Notes: Bits and Bytes and Numbers

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

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

Digital Logic Lecture 4 Binary Codes

Numbering systems. Dr Abu Arqoub

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

Bits, bytes, binary numbers, and the representation of information

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

Electronic Data and Instructions

Number Systems. TA: Mamun. References: Lecture notes of Introduction to Information Technologies (ITEC 1011) by Dr Scott MacKenzie

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

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

Bits. Binary Digits. 0 or 1

Discussion. Why do we use Base 10?

Computer Organization

Number Systems and Binary Arithmetic. Quantitative Analysis II Professor Bob Orr

UNIT 2 NUMBER SYSTEM AND PROGRAMMING LANGUAGES

Final Labs and Tutors

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

CHAPTER 2 (b) : AND CODES

Digital Systems and Binary Numbers

Number codes nibble byte word double word

Representing Characters, Strings and Text

Switching Circuits and Logic Design Prof. Indranil Sengupta Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur

CMSC 2833 Lecture 18. Parity Add a bit to make the number of ones (1s) transmitted odd.

Number System. Introduction. Decimal Numbers

Module 1: Information Representation I -- Number Systems

[301] Bits and Memory. Tyler Caraza-Harter

Kinds Of Data CHAPTER 3 DATA REPRESENTATION. Numbers Are Different! Positional Number Systems. Text. Numbers. Other

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

Number Systems Base r

Ms Sandhya Rani Dash UNIT 2: NUMBER SYSTEM AND CODES. 1.1 Introduction

COMP2121: Microprocessors and Interfacing. Number Systems

COE 202: Digital Logic Design Number Systems Part 2. Dr. Ahmad Almulhem ahmadsm AT kfupm Phone: Office:

CMPE223/CMSE222 Digital Logic Design. Positional representation

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

Chap 1. Digital Computers and Information

Chapter 2. Data Representation in Computer Systems

Binary. Hexadecimal BINARY CODED DECIMAL

Chapter 1 Emad Felemban

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

CMSC 313 COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE PROGRAMMING LECTURE 01, SPRING 2013

Fundamentals of Programming (C)

The x86 Microprocessors. Introduction. The 80x86 Microprocessors. 1.1 Assembly Language

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

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

EE 8351 Digital Logic Circuits Ms. J.Jayaudhaya, ASP/EEE

Transcription:

umber Systems Inside today s computers, data is represented as 1 s and 0 s. These 1 s and 0 s might be stored magnetically on a disk, or as a state in a transistor. To perform useful operations on these 1 s and 0 s we have to organize them together into patterns that make up codes. This lecture is about ways to represent data in the codes and to illustrate different number systems that are used today. This is how data is fundamentally stored in the computer. Each 1 and 0 is called a bit. 4 bits is called a nibble. 8 bits is called a byte. 16/32/64 bits is called a word. The number depends upon the number of bits that can simultaneously be operated upon by the processor. Since we only have 1 s and 0 s available, the number system we will use inside the computer is the binary number system. We are used to the decimal number system. In decimal, we have ten symbols (0-9) that we can use. When all of the symbols are used up, we need to combine together two symbols to represent the next number (10). The most significant digit becomes our first digit, and the least significant digit cycles back to 0. The least significant digit increments until the symbols are used up, and which point the most significant digit is incremented to the next larger digit. This is just the familiar process of counting! The same process applies to the binary number system, but we only have two symbols available (0 and 1). When we run out of symbols, we need to combine them and increment the digits just as we would in a decimal, base 10, number system: Let s start counting to illustrate: Decimal Binary 0 0 1 1 2 10 3 11 4 100 5 101 6 110 7 111 8 1000 9 1001 10 1010 11 1011 12 1100 13 1101 14 1110 15 1111 16 10000 17 10001

Binary to Decimal Conversion The binary number system is positional where each binary digit has a weight based upon its position relative to the least significant bit (LSB). To convert a binary number to decimal, sum together the weights. Each weight is calculated by multiplying the bit by 2 i, where i is the index relative to the LSB. 1 1 0 1 1 2 4 2 3 2 2 2 1 2 0 Weight = 1*2 0 + 1*2 1 + 0*2 2 + 1*2 3 + 1*2 4 = 1*1 + 1*2 + 0*4 + 1*8 + 1*16 = 1+2+8+16 = 27 (base 10, decimal) What is 11111 in base 10? What is 10110101 in base 10? Decimal to Binary Conversion To convert a decimal number to its equivalent binary number representation, the easiest method is to use repeated division by 2. Each time, save the remainder. The first remainder is the least significant bit. The last remainder is the most significant bit. What is 27 in binary? 27 / 2 = 13 remainder 1 LSB 13 / 2 = 6 remainder 1 6 / 2 = 3 remainder 0 3 / 2 = 1 remainder 1 1 / 2 = 0 remainder 1 MSB Our final number is 11011. If using a calculator, watch to see if the quotient has a fraction. If it is 0.5 then the remainder was 1, and repeat the process with the whole part minus the fraction. What is 83 in binary? What is 255 in binary? Hexadecimal umbering The hexadecimal numbering system is the most common system seen today in representing raw computer data. This is because it is very convenient to represent 8 bits, or one byte of data.

Hexadecimal uses a base 16 numbering system. This means that we have 16 symbols to use for digits. Consequently, we must invent new digits beyond 9. The digits used in hex are the letters A,B,C,D,E, and F. If we start counting, we get the table below: Decimal Hexadecimal Binary 0 0 0000 1 1 0001 2 2 0010 3 3 0011 4 4 0100 5 5 0101 6 6 0110 7 7 0111 8 8 1000 9 9 1001 10 A 1010 11 B 1011 12 C 1100 13 D 1101 14 E 1110 15 F 1111 16 10 10000 17 11 10001 18 Hex to Decimal Conversion Converting hex to decimal is just like converting binary to decimal, except instead of powers of 2, we use powers of 16. That is, the LSB is 16 0, the next is 16 1, then 16 2, etc. To convert 35F in hex to decimal: 3 5 F 16 2 16 1 16 0 Weight = 15*16 0 + 5*16 1 + 3*16 2 = 15*1 + 5*16 + 3*256 = 863 base 10 What is F00D in octal converted to decimal? Decimal to Hex Conversion Converting decimal to hex is just like converting decimal to binary, except instead of dividing by 2, we divide by 16. To convert 254 to hex:

254 / 16 = 15 remainder 14 = E 15 / 16 = 0 remainder 15 = F So we get FE for 254. Again, note that if a calculator is being used, you may multiple the fraction remainder by 16 to produce the remainder. What is 423 in hex? Hex to Binary Conversion, Binary to Hex Going from hex to binary is similar to the process of converting from octal to binary. One must simply look up or compute the binary pattern of 4 bits for each hex code, and concatenate the codes together. To convert FE to binary: F = 1111 E = 1110 So FE in binary is 1111 1110 The same process applies in reverse by grouping together 4 bits at a time and then look up the hex digit for each group. Binary 11000100101 broken up into groups of 4: 0110 0010 0101 (note the 0 added as padding on the MSB to get up to 4 bits) 6 2 5 = 625 Hex Alphanumeric Codes So far we have only been discussing the representation of numbers. We would also like to represent alphanumeric characters. This includes letters, numbers, punctuation marks, and other special characters like % or / that appear on a typical keyboard. The most common code in the United States is ASCII, the American Standard Code for Information Interchange. ASCII is comprised of a 7 bit code. This means that we have 2 7 or 128 possible code groups. This is plenty for English as well as control functions such as the carriage return or linefeed functions. Another code is EBCDIC, extended binary coded decimal interchange code. EBCDIC was used on some mainframe systems but is now out of favor.

Page 128 of your book has a complete listing of ASCII codes. A small sample is shown below. Character ASCII Hex ASCII binary Integer Equivalent A 41 01000001 65 B 42 01000010 66 C 43 01000011 67 Z 5A 01011010 90 Note that the sequence of bits 01000001 could represent many things: it could be the number 65, or it might be the letter A. Or it could be something else entirely different! Ultimately it is up to the software in the computer to know what a sequence of bits represents and treat it accordingly. Since most computers store data in bytes, or 8 bits, there is 1 bit that may go unused (or used for parity, described below). Could we represent something like Chinese in ASCII, which has many more than 128 characters? The answer is we can t, because there are way more than 128 characters in Chinese. One way to represent languages such as Chinese is to use a different code. UNICODE is an international standard used to represent multiple languages. To address the shortcomings of ASCII, UNICODE uses 16 bits per character. This allows 2 16 or 65536 characters. When this is insufficient, there are extensions to support over a million characters. Most of the work in UNICODE has gone in efforts to define the codes for the particular languages. If you would like more information, visit http://www.unicode.org. Some example Unicode characters for Tibetan are shown below.

Side note: A common problem with software development occurs when a product needs to support foreign languages. Many products in the US are initially developed assuming ASCII. However, if the product is successful and needs to support something like French or German, it is often a difficult task to move the program from ASCII to UNICODE. Software developers need to carefully take into account future needs and design the software appropriately. If it is known up front that other languages may need to be supported, it is a relatively simple matter to support UNICODE up front, or to remove dependencies on ASCII. Parity Method for Error Detection It is very possible for errors to occur when reading or transmitting some data. A CD might have a speck of dust, turning a 0 into a 1. A radio transmission might encounter some electromagnetic interference. A magnetic disk might be going bad. There are many cases where there is a possibility that errors will occur such that the receiver does not receive the identical information that is stored or sent. Although the possibility of error in modern systems is fairly low, with gigabytes of data being sent, the probability of encountering one of these errors is high. One of the simplest schemes to detect, and sometimes correct, errors is the parity method. The parity method simply attaches a parity bit to a code group being sent. There are two types, even parity or odd parity. In even parity the value of the parity bit is chosen so that the total number of 1 s in the group is an even number, including the parity bit. In odd parity the value of the parity bit is chosen so that the total number of 1 s in the group is an odd number, including the parity bit. Consider the ASCII code for the letter A. The code is 1000001. If we are using even parity, we want to select a parity bit so that the total number of 1 bits is even. Since there are already an even number of 1 s, we must make the parity bit 0 so that there is still an even number of 1 s including the parity. The data that would be transmitted is then 01000001. If using odd parity, we want to select a parity bit so that the total number of 1 bits is odd. This means that for 1000001 we need to make the parity bit be a 1 to make the total number of 1 s be odd. The data that would be transmitted is then 11000001. Let s say there was an error during transmission of the letter A, and the receiver got 11000011. The receiver will count up the number of 1 s and see that it is even. However, using odd parity we should never have an even number of 1 s. Therefore, an error occurred and the receiver may ask the sender to re-transmit the data.

Note that this parity method only works for single bit errors. If there are multiple errors we may be out of luck. Unfortunately, this is often the case due to the bursty nature of most errors. For these cases, we need stronger methods of error detection and correction such as a checksum, cyclic redundancy check or LRC. (which we won t describe here). Using even parity, what would be the parity bit for 111010110100? Representing images, sound Our pattern of bits can represent more than just numbers. They can represent anything we want them to as long as the meaning can be mapped to a sequence of bits. Images are represented by a bitmap, or a sequence of bits that represent different colors. (Todo: more detail on bitmap representation in class) Sound is represented as a sample of intensities from a sound wave.