1 / 32

1.1 Data Representation

1.1 Data Representation. ASCII, Binary <-> Denary Conversion, Integer & Boolean data types. Learning Objectives:. Describe ASCII as character format data type and explain the use of this code. Describe the binary number system. Convert simple numbers between denary and binary.

Download Presentation

1.1 Data Representation

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 1.1 Data Representation ASCII, Binary <-> Denary Conversion, Integer & Boolean data types

  2. Learning Objectives: • Describe ASCII as character format data type and explain the use of this code. • Describe the binary number system. • Convert simple numbers between denary and binary.

  3. 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 0

  4. Bits and Bytes • A binary digit (1 or 0) is known as a ‘bit’, short for BInarydigiT. • In modern computers bits are grouped in 8 bit bytes. • A Nibbleis 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).

  5. Character set • The symbols that a computer (software) can recognise which are represented by binary codes that the computer understands.

  6. 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

  7. 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.

  8. 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 • Note: Letters have increasing values from a-z or A-Z.

  9. 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.

  10. Sorting • Characters are compared in turn from the start of each word (left side) until two characters are different. • The character with the highest ASCII value determines which is the second word. • If 2 words are the same when one ends then the longer word is the second word.

  11. Binary Arithmetic Rules • 0 + 0 = 0 • 0 + 1 = 1 • 1 + 0 = 1 • 1 + 1 = 0 (carry 1) • 1+1+1 = 1 (carry 1)

  12. 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.

  13. Decimal or Denary system • 134 = 100 + 30 + 4 • Each column is worth 10X as much as the last i.e. base 10 (10 fingers!).

  14. Binary system 134 = 128 + 4 + 2 Each column is worth 2X as much as the last i.e. base 2. Most Significant Bit (MIB) Least Significant Bit (LIB) Increasing Bit Status

  15. Binary – Decimal Spreadsheet Converter 1 • Try using it to ‘play’ with binary numbers. • http://mrleeict.comule.com/as/1%20Programming/1.1%20Data%20Representation/Binary-Decimal%20converter.xls

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

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

  18. Questions 1. Convert the following binary numbers to decimal. • 0011 • 3 • 0110 • 6 • 1010 • 10 • 01000001 • 65 • 01000101 • 69

  19. 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

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

  21. 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

  22. 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)

  23. Integers • Integers are whole numbers with which arithmetic can be done. • Stored by the computer as binary numbers using a whole number of bytes. • It is usual to use either 2 bytes (called short integers) or 4 bytes (called long integers), the difference being simply that long integers can store larger numbers.

  24. Boolean Variables • (Yes / No) or (True / False) data • Example uses - a particular bit in memory can be set to show if: • a disk drive is connected or not • the ‘Break’ key is pressed

  25. Plenary • What is meant by an ASCII character?

  26. Plenary • A member of a standard character set. • Set of binary codes the computer understands. • Represented in a single byte/7 or 8 bits used per character. • Standard nature allows for communication between systems.

  27. Plenary • A member of a standard character set. • Set of binary codes the computer understands. • Represented in a single byte/7 or 8 bits used per character. • Standard nature allows for communication between systems.

  28. Plenary • Convert 101 (denary) to binary.

  29. Plenary • 01100101

  30. Plenary • Convert 10011111 to denary.

  31. Plenary • 159

More Related