Data Representation, Number Systems and Base Conversions

Slides:



Advertisements
Similar presentations
Data Representation COE 202 Digital Logic Design Dr. Aiman El-Maleh
Advertisements

ICS312 Set 2 Representation of Numbers and Characters.
Lecture - 2 Number systems and computer data formats
Digital Fundamentals Floyd Chapter 2 Tenth Edition
04/03/10CPE1002 (c) Monash University1 Number Systems and Data Representation Monash University School of Network Computing CPE 1002.
VIT UNIVERSITY1 ECE 103 DIGITAL LOGIC DESIGN CHAPTER I NUMBER SYSTEMS AND CODES Reference: M. Morris Mano & Michael D. Ciletti, "Digital Design", Fourth.
Data Representation in Computers
Digital Fundamentals Floyd Chapter 2 Tenth Edition
S. Barua – CPSC 240 CHAPTER 2 BITS, DATA TYPES, & OPERATIONS Topics to be covered are Number systems.
The Binary Number System
Digital Logic Chapter 2 Number Conversions Digital Systems by Tocci.
Connecting with Computer Science 2 Objectives Learn why numbering systems are important to understand Refresh your knowledge of powers of numbers Learn.
Dr. Bernard Chen Ph.D. University of Central Arkansas
Data Representation in Computers
Data Representation Number Systems.
©Brooks/Cole, 2003 Chapter 2 Data Representation.
© 2009 Pearson Education, Upper Saddle River, NJ All Rights ReservedFloyd, Digital Fundamentals, 10 th ed Digital Fundamentals Tenth Edition Floyd.
Programmable Logic Controllers
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.
EKT 121 / 4 ELEKTRONIK DIGIT 1 CHAPTER 1 : INTRODUCTION.
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.
Chapter 3 Data Representation
Binary Arithmetic & Data representation
EE2174: Digital Logic and Lab Professor Shiyan Hu Department of Electrical and Computer Engineering Michigan Technological University CHAPTER 2 Number.
NUMBER SYSTEM AND COMPUTER CODES Chapter 2. Prelude Fingers, sticks, and other things for counting were not enough! Counting large numbers Count in groups.
Number Systems Spring Semester 2013Programming and Data Structure1.
ICS312 Set 1 Representation of Numbers and Characters.
Information Representation. Digital Hardware Systems Digital Systems Digital vs. Analog Waveforms Analog: values vary over a broad range continuously.
Logic Design Dr. Yosry A. Azzam. Binary systems Chapter 1.
Number systems & Binary codes MODULE 1 Digital Logic Design Ch1-2 Outline of Chapter 1  1.1 Digital Systems  1.2 Binary Numbers  1.3 Number-base Conversions.
Computer Systems Architecture Copyright © Genetic Computer School 2008 CSA 1- 0 Lesson 1 Number System.
Number systems, Operations, and Codes
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 Conversion 24/04/2017.
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.
CHAPTER 1 INTRODUCTION TO DIGITAL LOGIC
AEEE2031 Data Representation and Numbering Systems.
Number Systems Denary Base 10 Binary Base 2 Hexadecimal Base 16
Digital Fundamentals Tenth Edition Floyd Chapter 2 © 2008 Pearson Education.
MECH1500 Chapter 3.
Chapter 1 : Introduction to Binary Systems 1.1. Introduction to Digital Systems 1.2. Binary Numbers 1.3. Number Base Conversion 1.4. Octal and Hexadecimal.
Computer Math CPS120 Introduction to Computer Science Lecture 7.
Number Systems. ASCII – American Standard Code for Information Interchange – Standard encoding scheme used to represent characters in binary format on.
CHAPTER 3 BINARY NUMBER SYSTEM. Computers are electronic machines which operate using binary logic. These devices use two different values to represent.
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.
Programming and Data Structure
Number Systems and Codes
NUMBER SYSTEMS.
Number Representation
3.1 Denary, Binary and Hexadecimal Number Systems
CHAPTER 1 : INTRODUCTION
ITE102 – Computer Programming (C++)
Chapter 3 Data Representation
Why use Binary? There are only four rules for addition in binary compared to 100 in decimal [0+0=0 ; 0+1=1 ; 1+0=1; 1+1=10]
IT 0213: INTRODUCTION TO COMPUTER ARCHITECTURE
University of Gujrat Department of Computer Science
Numbering System TODAY AND TOMORROW 11th Edition
Why use Binary? It is a two state system (on/off) which makes it simple to operate Even if degradation of current occurs (ie a slight drop in voltage)
Chapter Four Data Representation in Computers By Bezawit E.
UNIT – 3 & 4. Data Representation and Internal
Chapter 3 - Binary Numbering System
CHAPTER 69 NUMBER SYSTEMS AND CODES
Presentation transcript:

Data Representation, Number Systems and Base Conversions Computer Orgn & Arch 2011

Chapter Outline Numeric data representation systems Binary, octal, and hexadecimal Non-numeric data representation ASCII and EBCDIC, UNICODE Representation of numbers Integers, floating point and Binary coded decimal Number base conversions Computer Orgn & Arch 2011

Number systems and computers The BINARY number system is a positional number system with similar properties to the decimal system. However, we often need to convert binary to a number system we are familiar with (decimal) or a system that is easier for humans to use. Computer programs and data are often represented using octal and hexadecimal number systems because they are a short hand way of representing binary numbers. Computer Orgn & Arch 2011

Binary presentation of data Sometimes binary numbers need to be converted to Hexadecimal (hex) numbers which reduces a long string of binary digits to a few hexadecimal characters. This makes it easier to remember and to work with the numbers. Computer Orgn & Arch 2011

Numeric Data representation Deals with the representation of numbers in a computer. In digital computers, the most commonly used number systems are: binary octal hexadecimal Number System Radix (base) Digits used Decimal 10 0, 1, .....,9 Binary 2 0, 1 Octal 8 0, 1, ......, 7 Hexadecimal 16 0, 1, ..., 9, A, B, ..., Computer Orgn & Arch 2011

There are three Numbers formats in computer world. Integer or fixed point format Floating point format Binary Coded Decimal format (BCD) Computer Orgn & Arch 2011

Numeric Data representation Numeric data can be Integers - fixed-point numbers (no fractional part) Unsigned integers. the standard binary encoding already given. Supports only positive values Signed Magnitude integers. This is another way or representing negative integers. Involves treating the most significant (left most) bit in the word as a sign bit .Positive-0, negative -1. example: 4 bits, 0101 is 5 &1101 is -5 Floating-point numbers - numbers with fractional components Computer Orgn & Arch 2011

Binary Coded Decimal When data is entered , it must be converted into some binary form before processing can begin. This is called BCD In BCD, each figure of the number to be coded is represented by its 4 bits binary equivalent Example 8159=1000 0001 0101 1001

There are two BCD formats; Packed(condensed) and Extended(unpacked) Computer Orgn & Arch 2011

Formats Packed, each figure occupies half a byte. Eg 341= 0011 0100 0001 Unpacked, each decimal figure is represented by a byte. Eg 341=00000011 00000100 00000001 Hardware designed for BCD is more complex than that for binary formats Advantage, its closer to the alphanumeric codes.

Number Base Conversions Two techniques available: Repeated division Bit grouping Computer Orgn & Arch 2011

Number Base Conversions (Cont) Repeated Division Technique To convert a number in base  to the equivalent number in base , divide the given number by base  using base  arithmetic. Computer Orgn & Arch 2011

Number Base Conversions (Cont) Bit Grouping Technique Employed for conversion between octal and binary and for the conversion between hexadecimal and binary. Each hexadecimal digit corresponds to a group of four binary bits. Each octal digit corresponds to a group of three binary bits. Computer Orgn & Arch 2011

Number Base Conversions (Cont) Binary to Octal and Octal to Binary To convert a binary number to octal, simply split up the binary number into 3-bit groups starting from the least significant bit and get the corresponding octal digits. Qn . Convert 1001101 to octal . 1001101.0111 to octal To convert an octal number to binary, for each octal digit, get the equivalent 3-bit binary representation. Computer Orgn & Arch 2011

Number Systems - Hexadecimal The hexadecimal system is a base-16 system. It contains the digits 0 to 9 and the letters A to F. The letters A to F represent the decimal numbers 10 to 15. Decimal Hexadecimal 0,1,2…9 0,1,2…..9 10 A 11 B 12 C 13 D 14 E 15 F Computer Orgn & Arch 2011

Number Systems - Hexadecimal Conversion to binary is done the same way as octal to binary, but binary digits are organized into groups of 4. Conversion from binary to hexadecimal involves breaking the bits into groups of 4 and replacing them with the hexadecimal equivalent. Computer Orgn & Arch 2011

Hexadecimal - Binary conversions 0 0000 1 0001 2 0010 3 0011 4 0100 5 0101 6 0110 7 0111 8 1000 9 1001 A 1010 B 1011 C 1100 D 1101 E 1110 F 1111 Hex to binary: (Bit group repeating) 1D7F16 = 0001 1101 0111 11112 5AB216 = 0101 1010 1011 00102 Binary to hex: 1110 0011 0000 11002 = E30C16 1001 1000 1101 11112= 98DF16 Computer Orgn & Arch 2011

Number Base Conversions (Cont) Binary to hex and hex to binary To convert a binary number to hexadecimal, simply split up the binary number into 4-bit groups starting from the least significant bit and get the corresponding hexadecimal digits. Qn. Convert 1001101 to Hex. To convert a hexadecimal number to binary, for each hexadecimal digit, get the equivalent 4-bit binary representation. Computer Orgn & Arch 2011

Number Systems - Octal An octal number can easily be converted to binary by replacing each octal digit with the corresponding group of 3 binary digits. Octal 0 1 2 3 4 5 6 7 Binary 000 001 010 011 100 101 110 111 Computer Orgn & Arch 2011

Data representation Human brain can process large variety of data including: characters numbers images and sounds touch, smell and taste Current technology limits data that computer can efficiently manipulate to numeric data. Therefore, ALL data - no matter how complex - must be represented (encoded) in the computers memory in numeric form. Computer Orgn & Arch 2011

Data Representation Computers represent data using binary numbers because: It is easy to represent binary numbers as electrical states or signals which can be processed by two-state (on-off) electrical devices (eg transistors) . Standardization; organizations have created standard data encoding methods for communication among computer systems and their components.   Computer Orgn & Arch 2011

Number Systems - Decimal The decimal system is a base-10 system. There are 10 distinct digits (0 to 9) used to represent any quantity. For an n-digit number, the value that each digit represents depends on its weight or position. The weights are based on powers of 10. 4TH. 3RD. 2ND. 1ST. POSITION 103 = 1000 102 = 100 101 = 10 100 = 1 WEIGHT For example, 491610 = 4*1000 + 9*100 + 1*10 +6*1 Computer Orgn & Arch 2011

Base 10 number systems Base 10 uses the ten symbols 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9 which are combined to represent all possible numeric values.  The decimal number system is based on powers of 10. Each column position of a value, from right to left, is multiplied by the number 10, which is the base number, raised to a power, which is the exponent. The power that 10 is raised to depends on its position to the left of the decimal point. Computer Orgn & Arch 2011

Number Systems - Binary The binary system is a base-2 system. There are 2 distinct digits (0 and 1) to represent any quantity. For an n-digit number, the value that each digit represents depends on its weight or position. The weights are based on powers of 2. 8TH 7TH 6TH 5TH 4TH 3RD 2ND 1ST POSITION 27=128 26=64 25=32 24=16 23=8 22=4 21=2 20=1 WEIGHT For example: 110100102 = 1*128 + 1*64 + 0*32 + 1*16 + 0*8 + 0*4 + 1*2 +0*1 = 21010 Computer Orgn & Arch 2011

Converting decimal numbers to 8-bit binary numbers Example: Convert the binary number 01110000 to a decimal number. Note: Work from right to left. Remember that anything raised to the 0 power is 1. Therefore 20 = 1   0 x 20 =   0 0 x 21 =   0   0 x 22 =   0   0 x 23 =   0  1 x 24 = 16  1 x 25 = 32   1 x 26 = 64 + 0 x 27=   0 –––––––––––             112  Computer Orgn & Arch 2011

Number Systems - Octal Octal and hexadecimal systems provide a shorthand way to deal with the long strings of 1’s and 0’s in binary. Octal is a base-8 system using the digits 0 to 7. To convert to decimal, you can again use a weighted system eg. 75128 = 7*83 + 5*82 + 1*81 + 2*80 = 391410 To convert to decimal, you can again use a weighted system. 3216 = ? Computer Orgn & Arch 2011

Decimal to Base-n Conversions To convert from decimal to a different number base such as octal, binary or hexadecimal involves repeated division by that number base. Keep dividing until the quotient is zero Use the remainders in reverse order Computer Orgn & Arch 2011

Decimal to Base-n Conversions Decimal to Octal Decimal to Hex 8 |674 16 |735 8 |84  2 (*80) 16 |45  F (*160) 8 |10  4 (*81) 16 | 2  D (*161) 8 | 1  2 (*82) 16 | 0  2 (*162) 8 | 0  1 (*83) 0 Answer: 12428 Answer: 2DF16 Computer Orgn & Arch 2011

Computer Orgn & Arch 2011

Adding numbers So to add the numbers 0610=01102 and 0710=01112 (answer=1310=11012) we can write out the calculation Decimal Unsigned Binary 1 (carry) 06 +07 13 110 (carry) 0110 +0111 1101 Computer Orgn & Arch 2011

Multiplying number Decimal Binary For example, 00101001 × 00000110 = 11110110          0  0  1  0  1  0  0  1 = 41 (base10)     × 0  0  0  0  0  1  1  0 = 6 (base 10)     0  0  0  0  0  0  0  0   0  0  1  0  1  0  0  1      0  0  1  0  1  0  0  1         0  0  1  1  1  1  0  1  1  0 = 246 (base 10)    Computer Orgn & Arch 2011

Rules of Binary Subtraction 0 - 0 = 0 0 - 1 = 1, and borrow 1 from the next more significant bit 1 - 0 = 1 1 - 1 = 0 For example, 00100101 - 00010001 = 00010100                  0   borrows   0  0  1 10  0  1  0  1 =37 (base10)     - 0  0  0  1  0  0  0  1 =17 (base 10)       0  0  0  1  0  1  0  0 =20 (base10)     Computer Orgn & Arch 2011

Non-numeric Data Representation Alphanumeric codes are used when the computing device has to handle letters and special symbols as well as decimal digits. Two dominant coding schemes are: ASCII (American Standard Code for Information Interchange) EBCDIC (Extended Binary Coded decimal Interchange Code) Computer Orgn & Arch 2011

Alphanumeric Codes There are three main coding methods in use: The American Standard Code for Information Interchange (ASCII) Extended Binary Coded Decimal Interchange Code (EBCDIC) Unicode. Computer Orgn & Arch 2011

Alphanumeric Data Alphanumeric (character) data such as names and addresses are represented by assigning a unique binary code or sequence of bits to represent each character. As each character is entered from a keyboard (or other input device) it is converted into its binary code. Computer Orgn & Arch 2011

Alphanumeric Data Character code sets contain two classes of codes: Printable (normal characters) Non-printable ie. characters used as control codes. For example: CTRL G CTRL Z . Most computers use ASCII codes to represent text, which makes it possible to transfer data from one computer to another. ASCII (128 characters) Computer Orgn & Arch 2011

ASCII ASCII 7-bit code (128 characters) has an extended 8-bit version used on PC’s and non-IBM mainframes Was widely used to transfer data from one computer to another – now being replaced by Unicode Computer Orgn & Arch 2011

ASCII ASCII is a code for representing English characters as numbers, with each letter assigned a number from 0 to 127. Each character has a unique pattern of eight binary digits assigned to represent it. Computer Orgn & Arch 2011

ASCII Coding Examples An ASCII subset “CAB” = 43414216 F 46 0 30 1 31 2 32 3 33 4 34 5 35 6 36 7 37 Symbol Code “CAB” = 43414216 = 0100 0011 0100 0001 0100 00102 “F1” = 463116 = 0100 0110 0011 00012 “3415” = 3334313516 = 0011 0011 0011 0100 0011 0001 0011 01012 *Note that this is a text string and no arithmetic may be done on it. A postcode is a good example of storing numbers as text. Computer Orgn & Arch 2011

Alphanumeric Codes EBCDIC an 8-bit code (256 characters) used on mainframe IBM machines. The binary code for text as well as communications and printer control from IBM Both ASCII and EBCDIC are inadequate for representing all international characters. eg Chinese characters Computer Orgn & Arch 2011

Alphanumeric Codes Unicode - recent 16 bit standard - can represent 65 thousand characters, of which 49,000 have been defined, incorporates ASCII-7 as subset. Computer Orgn & Arch 2011

Both of those are 1 byte per character Both of those are 1 byte per character. ( ASCII & EBCDIC) Unicode is a coding where characters require 2 bytes per character. Windows can use unicode, but it is not required. It is useful if extra characters not supported in the 1 byte character sets are needed in the same document. Computer Orgn & Arch 2011

Representing Images Two popular techniques used Bitmap techniques .  image composed of pixels is known as a bitmapped image  Vector techniques. Vector graphics is the use of geometrical primitives such as points, lines, curves, and shapes or polygon(s), which are all based on mathematical equations, to represent images in computer graphics. Computer Orgn & Arch 2011