Data Representation Conversion 05/12/2018.

Slides:



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

A-Level Computing#BristolMet Session Objectives#8 express numbers in binary, octal and hexadecimal explain the use of code to represent a character set.
Company LOGO Edit your slogan here DKT 122/3 DIGITAL SYSTEM 1 WEEK #3 NUMBER SYSTEMS, OPERATION & CODES (PART 2)
Digital Fundamentals Floyd Chapter 2 Tenth Edition
Binary Representation
Number Systems and Codes In PLC
Digital Logic Chapter 2 Number Conversions Digital Systems by Tocci.
© 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.
Introduction to Number Representation F451 Year 10 Computing Binary Numbers Binary Numbers Sign/Magnitude Sign/Magnitude 2s Complement 2s Complement Binary.
EKT 121 / 4 ELEKTRONIK DIGIT 1 CHAPTER 1 : INTRODUCTION.
Data Representation S2. This unit covers how the computer represents- Numbers Text Graphics Control.
Objectives Data Representation Binary number system Binary Coded Decimal (BCD) Boolean Values Analogue & Digital data Use of ASCII code Memory addressing.
Binary Arithmetic & Data representation
07/10/ Strings ASCII& Processing Strings with the Functions - Locate (Instr), Mid, Length (Len), Char (ChrW) & ASCII (Asc)
EX_01.1/46 Numeric Systems. EX_01.2/46 Overview Numeric systems – general, Binary numbers, Octal numbers, Hexadecimal system, Data units, ASCII code,
Computing Theory – F453 Number Systems. Data in a computer needs to be represented in a format the computer understands. This does not necessarily mean.
CS151 Introduction to Digital Design
Computer Systems Architecture Copyright © Genetic Computer School 2008 CSA 1- 0 Lesson 1 Number System.
CCE-EDUSAT SESSION FOR COMPUTER FUNDAMENTALS Date: Session III Topic: Number Systems Faculty: Anita Kanavalli Department of CSE M S Ramaiah.
Data Representation Conversion 24/04/2017.
Data Representation, Number Systems and Base Conversions
AEEE2031 Data Representation and Numbering Systems.
Number Bases and Representation. Denary Number System (Base 10) Our number system uses 10 digits (0-9) As you move from right to left each number is worth.
Candidates should be able to:
Number Systems Denary Base 10 Binary Base 2 Hexadecimal Base 16
Number Systems by Dr. Amin Danial Asham. References  Programmable Controllers- Theory and Implementation, 2nd Edition, L.A. Bryan and E.A. Bryan.
Digital Fundamentals Tenth Edition Floyd Chapter 2 © 2008 Pearson Education.
MECH1500 Chapter 3.
09/06/ Data Representation ASCII, Binary Denary Conversion, Integer & Boolean data types.
 Computers are 2-state devices › Pulse – No pulse › On – Off  Represented by › 1 – 0  BINARY.
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.
DATA Unit 2 Topic 2. Different Types of Data ASCII code: ASCII - The American Standard Code for Information Interchange is a standard seven-bit code that.
3.1 Denary, Binary and Hexadecimal Number Systems We use the denary (base 10) number system in our daily life for counting and calculation. Computers use.
Programmable Logic Controller
Understanding binary Understanding Computers.
Number Systems and Codes
NUMBER SYSTEMS.
3.1 Denary, Binary and Hexadecimal Number Systems
Data Representation Binary Numbers Binary Addition
Lesson Objectives Aims
ENEL 111 Digital Electronics
CHAPTER 1 : INTRODUCTION
Introduction to Chapter 2
Digital Electronics Jess 2008.
Introduction The term digital is derived from the way computers perform operation, by counting digits. Application of digital technology: television, communication.
…to GCSE Level with Python Sue Sentance
IT 0213: INTRODUCTION TO COMPUTER ARCHITECTURE
2 Number Systems and Codes Edited by Jerry Bernardini.
Data Structures Mohammed Thajeel To the second year students
BEE1244 Digital System and Electronics BEE1244 Digital System and Electronic Chapter 2 Number Systems.
Representing Characters
Number Systems and Codes
Decimal System The radix or base of a number system determines
MMNSS COLLEGE,KOTTIYAM DEPARTMENT OF PHYSICS
Numbering System TODAY AND TOMORROW 11th Edition
4.1 Strings ASCII & Processing Strings with the Functions
C1 Number systems.
Storing Negative Integers
23/04/2019 Data Representation Conversion.
WJEC GCSE Computer Science
Binary.
Chapter 3 - Binary Numbering System
ENEL 111 Digital Electronics
CHAPTER 69 NUMBER SYSTEMS AND CODES
Two’s Complement & Binary Arithmetic
Section 6 Primitive Data Types
Presentation transcript:

Data Representation Conversion 05/12/2018

Learning Objectives: Show understanding of the basis of different number systems and use the binary, denary and hexadecimal number system. Convert a number from one number system to another. Show understanding of, and be able to represent, character data in its internal binary form depending on the character set used (Candidates will not be expected to memorise any particular character codes but must be familiar with ASCII and Unicode). Express a denary number in Binary Coded Decimal (BCD) and vice versa. Describe practical applications where BCD is used. 05/12/2018

The Binary System Computers store information (data of all types – numbers, characters, sound, pictures, …) in Binary format i.e. base 2. i.e. 0 or 1 Used because computers can only store and understand 2 states: i.e. whether a circuit has current flowing or not / circuit is closed or open / voltage is high or low. 1 05/12/2018

Bits and Bytes A binary digit (1 or 0) is known as a ‘bit’, short for BInary digiT. In modern computers bits are grouped in 8 bit bytes. A Nibble is 4 bits (half a byte). A Word is the number of bits that the CPU can process simultaneously. Determines the speed of the computer. Processors can have 8-, 16-, 32-(standard) or 64-(fast) bit word sizes (or more). 05/12/2018

Character set The symbols that a computer (software) can recognise which are represented by binary codes that the computer understands. 05/12/2018

Character Representation Over the years different computer designers have used different sets of binary codes for representing characters in a character set. This has led to great difficulty in transferring information from one computer to another. i.e. which binary code represents each character 05/12/2018

ASCII (American Standard Code for Information Interchange) Represents each character in a standard character set as a single byte binary code. The standard code form that most PCs use to allow for communication between systems. Usually uses a 7 bit binary code so can store 128 different characters and simple communications protocols. Sufficient for all characters on a standard keyboard plus control codes. Can be extended (extended ASCII) to use 8 bits (so can store 256 characters) to encode Latin language characters. 05/12/2018

ASCII code The first 32 ASCII codes are used for simple communications protocols, not characters. e.g. ACK – acknowledge and would be sent by a device to acknowledge receipt of data. 0110010 – 2 0110001 – 1 ….. 1000001 – A 1000010 – B 05/12/2018

Representing Characters and Numbers e.g. If the ‘A’ key is pressed ‘1000001’ is sent to the CPU. If the 1 key is pressed then ‘0110001’ is sent to the CPU. If the user wants to print ‘123’ the codes for 1, 2 & 3 are sent to the printer. 05/12/2018

Binary Arithmetic Rules 0 + 0 = 0 0 + 1 = 1 1 + 0 = 1 1 + 1 = 0 (carry 1) 1+1+1 = 1 (carry 1) 05/12/2018

Arithmetic ASCII coding is fine for input and output but useless for arithmetic: 2 0110010 -1 - 0110001 1 0000000 i.e. not 1 There is no easy way to perform calculations on the numbers stored in this way. Numbers which are to be used in calculations are therefore held in binary format. 05/12/2018

Decimal or Denary system 134 = 100 + 30 + 4 Each column is worth 10X as much as the last i.e. base 10 (10 fingers!). 100 10 1 3 4 05/12/2018

Binary system 134 = 128 + 4 + 2 Each column is worth 2X as much as the last i.e. base 2. 128 64 32 16 8 4 2 1 Most Significant Bit (MSB) Least Significant Bit (LSB) Increasing Bit Status 05/12/2018

Binary – Decimal Spreadsheet Converter 1 Try using it to ‘play’ with binary numbers. On the website below the link to this presentation. 05/12/2018

Denary -> Binary e.g. 117 Always use the column headings for a byte (8 bits). 117 < 128 so put a 0 and repeat. 128 64 32 16 8 4 2 1 117 > 64 so put a 1. 128 64 32 16 8 4 2 1 117 - 64 = 53 , 53 > 32, so put a 1. 128 64 32 16 8 4 2 1 53 - 32 = 21 , 21 > 16, so put a 1. Continue this until: 128 64 32 16 8 4 2 1

Binary -> Denary e.g. 10110110 So 10110110 = 128 + 32 + 16 + 4 + 2 Put the column headings above the binary number and add up all the columns with a 1 in them. 128 64 32 16 8 4 2 1 So 10110110 = 128 + 32 + 16 + 4 + 2 = 182 (denary)

Questions 1. Convert the following binary numbers to decimal. 0011 3 0110 6 1010 10 01000001 65 01000101 69 05/12/2018

8 bit patterns Because in modern computers bits are grouped in 8 bit bytes numbers in binary format are usually written in 8 bit patterns even if there are unnecessary left leading 0’s. e.g. 11(binary) = 3 (decimal) But you will usually find it written as 00000011 05/12/2018

Decimal -> Binary Questions 2. Convert the following decimal numbers to binary: 5 00000101 7 00000111 1 00000001 26 00011010 68 01000100 137 10001001 05/12/2018

Size of number Using only one byte to hold a number of places a restriction on the size of number the computer can hold. Therefore four or more consecutive bytes are commonly used to store numbers 05/12/2018

Binary -> Decimal Questions 3. What is the largest decimal number that can be held in (hint: 2^no. of bits): 1 byte 255 (2^8 - 1) 2 bytes 65535 (2^16 - 1) 3 bytes 16777215 (2^24 - 1) 4 bytes 4294967295 (2^32-1) 05/12/2018

Hexadecimal Counts in 16’s. Uses the digits 0 – 9 and letters A – F. We need symbols going further than 0 to 9 (only 10 symbols and we need 16!). We could invent 6 more symbols but we would have to learn them, so we use 6 that we already know, the letters A to F. Each digit is worth 16X as much as the one to the right. Each hex bit = 4 binary bits. e.g. F (decimal 15) = 1111 05/12/2018

Hexadecimal Denary / Decimal Binary Hexadecimal 1 00000001 2 00000010 etc …. 9 00001001 10 00001010 A 11 00001011 B 15 00001111 F 16 00010000 05/12/2018

Decimal -> Hexadecimal e.g. 75 Use the column headings 1, 16, 256, … (16^n) 75 < 4096 & 75 < 256 so put a 0. 4096 256 16 1 75 > 16 & 75 / 16 = 4 r 11 11= B (hexadecimal) 4096 256 16 1 4 B So 75 = 4B (Hexadecimal)

Hexadecimal-Denary Converter Try using it to ‘play’ with hexadecimal numbers. https://4565e4f1bb6fcb191b6a80b2e8cd1502a3f5fc3b.googledrive.com/host/0BxvAvCIUrln7bjJWaDAwZ0lBVFU/as_computer_science/information_rep/hexadecimal-denary_converter.xls 05/12/2018 25

Denary -> Hexadecimal Question: Translate 101 (denary) into hexadecimal. 65 Translate 64 (denary) into hexadecimal. 40 05/12/2018

Hexadecimal -> Denary e.g. BD 4096 256 16 1 B D 11 13 B = 11 , D = 13 BD = (11 * 16) + 13 = 176 + 13 = 189 ( in denary) 05/12/2018

Hexadecimal -> Denary Question: Translate 96 (hexadecimal) into denary. 150 Translate the 75 (hexadecimal) into denary. 117 Translate the 30 (hexadecimal) into denary. 48 05/12/2018

Binary -> Hexadecimal Translate each group of 4 bits into denary and then into hexadecimal. e.g. 10010010 (binary) = (1001)(0010) = (9)(2) = 92 (hexadecimal) An alternative way to convert from denary to hexadecimal is to convert to binary and then do the above. Subsequently, vice versa for hexadecimal to denary. 05/12/2018

Hexadecimal In order to ease the task of examining the contents of memory or a computer file, binary numbers are commonly put into groups of 4 bits and displayed in the form of hexadecimal numbers, base 16. Used as a shorthand for binary. 05/12/2018

Questions: The ASCII code for the letter N is 0100 1110. Show how to represent this in a) denary 78 b) hexadecimal = (0100) (1110) = (4 + 14) = 4E 05/12/2018

BCD (Binary Coded Decimal) Represents numbers only by representing each decimal digit by a 4 bit binary code. Decimal Binary 0000 1 0001 2 0010 etc.... 9 1001 e.g. 19 is shown by: 1 9 0001 1001 05/12/2018

Denary -> BCD Question Convert 398602 (denary) into BCD. 001110011000011000000010 05/12/2018

BCD -> Denary e.g. 001001110110 Split into groups of 4. (0010) (0111) (0110) Translate each group of 4 into decimal in the same fashion as binary -> decimal. 2 7 6 So 001001110110 = 276 (denary) 05/12/2018

BCD -> Denary Question Convert 100000110101 (BCD) into denary. 835 05/12/2018

BCD (Binary Coded Decimal) Advantages: Easy to convert from BCD to decimal and vice versa: as a BCD number is split into groups of four bits and each group converted directly to the corresponding decimal digit Used in some pocket calculators 05/12/2018

. Fixed Point Binary 8 4 2 1 ½ ¼ 1/8 1/16 6.75 = 0110.1100 A number with a decimal point is known (strangely!) as a real number as opposed to an integer which is a whole number. We can extend the binary system to represent real numbers by reserving some bits for the real or fractional part. 8 4 2 1 ½ ¼ 1/8 1/16 . 6.75 = 0110.1100 05/12/2018

Fixed Point Binary Precision 110.1 = 6.5 110.11 = 6.75 We have missed out 6.51 to 6.74! This means accuracy is poor. 05/12/2018

BCD (Binary Coded Decimal) Advantages: When storing fractional numbers in BCD no ‘rounding’ occurs: As each digit is encoded separately so as many bits as necessary are used to represent the complete number Used in business applications where every significant digit has to be retained in a result. 05/12/2018

BCD (Binary Coded Decimal) Disadvantage More bits are required to store each number than pure binary e.g. 19 in BCD = 0001 1001 (8 bits) 19 in normal binary format = 10011 (5 bits) Difficult to calculate with: e.g. 1 0000 0001 + 19 0001 1001 20 0001 1010 ‘10’ is wrong invalid 05/12/2018

BCD (Binary Coded Decimal) Only the first ten out of 16 combinations of 4 digits are used to encode the decimal digits ‘0’ to ‘9’ Therefore whenever the sum of two binary digits is >9, 6 has to be added to skip over the 6 unused codes. e.g. 1 0000 0001 + 19 +0001 1001 20 0001 1010 + 0110 0010 0000 i.e. 20 which is correct 05/12/2018

Unicode 16 bit code so can store 65536 characters and codes and simple communications protocols. Used to allow coding of languages that do not use Western characters. Currently supports 24 language scripts. 05/12/2018

Plenary Express the denary value 109 as A binary number using an 8-bit byte. A hexadecimal number.      A number in binary coded decimal (BCD). 05/12/2018

Plenary 01101101 6D 0001 0000 1001 05/12/2018