Presentation is loading. Please wait.

Presentation is loading. Please wait.

09/06/20161 1.1 Data Representation ASCII, Binary Denary Conversion, Integer & Boolean data types.

Similar presentations


Presentation on theme: "09/06/20161 1.1 Data Representation ASCII, Binary Denary Conversion, Integer & Boolean data types."— Presentation transcript:

1 09/06/20161 1.1 Data Representation ASCII, Binary Denary Conversion, Integer & Boolean data types

2 209/06/2016 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 309/06/2016 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 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. i.e. whether a circuit has current flowing or not / circuit is closed or open / voltage is high or low. 10

4 409/06/2016 Bits and Bytes A binary digit (1 or 0) is known as a ‘bit’, short for BI nary digi T. In modern computers bits are grouped in 8 bit bytes. A 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. Determines the speed of the computer. Processors can have 8-, 16-, 32-(standard) or 64- (fast) bit word sizes (or more). Processors can have 8-, 16-, 32-(standard) or 64- (fast) bit word sizes (or more).

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

6 609/06/2016 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 i.e. which binary code represents each character

7 709/06/2016 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. 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 1009/06/2016 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 1109/06/2016 Binary Arithmetic Rules 0 + 0 = 0 0 + 1 = 1 1 + 0 = 1 1 + 1 = 0 (carry 1) 1+1+1 = 1 (carry 1)

12 1209/06/2016 Arithmetic ASCII coding is fine for input and output but useless for arithmetic: 2 0110010 2 0110010 -1- 0110001 -1- 0110001 1 0000000 i.e. not 1 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 1309/06/2016 Decimal or Denary system 134 = 100 + 30 + 4 Each column is worth 10X as much as the last i.e. base 10 (10 fingers!). 100101 134

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

15 1509/06/2016 Binary – Decimal Spreadsheet Converter 1 Try using it to ‘play’ with binary numbers. https://4565e4f1bb6fcb191b6a80b2e8cd1502a3f5fc3b.googledrive.com/ host/0BxvAvCIUrln7bjJWaDAwZ0lBVFU/as/1%20Programming/1.1%20 Data%20Representation/Binary-Decimal%20converter.xls https://4565e4f1bb6fcb191b6a80b2e8cd1502a3f5fc3b.googledrive.com/ host/0BxvAvCIUrln7bjJWaDAwZ0lBVFU/as/1%20Programming/1.1%20 Data%20Representation/Binary-Decimal%20converter.xls https://4565e4f1bb6fcb191b6a80b2e8cd1502a3f5fc3b.googledrive.com/ host/0BxvAvCIUrln7bjJWaDAwZ0lBVFU/as/1%20Programming/1.1%20 Data%20Representation/Binary-Decimal%20converter.xls https://4565e4f1bb6fcb191b6a80b2e8cd1502a3f5fc3b.googledrive.com/ host/0BxvAvCIUrln7bjJWaDAwZ0lBVFU/as/1%20Programming/1.1%20 Data%20Representation/Binary-Decimal%20converter.xls

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

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

18 1809/06/2016 Questions 1. Convert the following binary numbers to decimal. 0011 00113 0110 01106 1010 101010 01000001 0100000165 01000101 0100010169

19 1909/06/2016 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) e.g. 11(binary) = 3 (decimal) But you will usually find it written as 00000011 But you will usually find it written as 00000011

20 2009/06/2016 Decimal -> Binary Questions 2. Convert the following decimal numbers to binary: 500000101 700000111 100000001 26 2600011010 68 6801000100 137 13710001001

21 2109/06/2016 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 2209/06/2016 Binary -> Decimal Questions 3. What is the largest decimal number that can be held in (hint: 2^no. of bits): 1 byte 1 byte 255 (2^8 - 1) 2 bytes 2 bytes 65535 (2^16 - 1) 65535 (2^16 - 1) 3 bytes 3 bytes 16777215 (2^24 - 1) 4 bytes 4 bytes 4294967295 (2^32-1)

23 2309/06/2016 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 2409/06/2016 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 a disk drive is connected or not the ‘Break’ key is pressed the ‘Break’ key is pressed

25 Main Data Types Data Types Range / Fractional Real Precision Storage Requirements (bytes) Whole numbers, no fractions Integer (Numeric, Whole numbers, no fractions) Byte 0 - 255 1 Short Integer In Access stored by 2 bytes so +/- 32,768. In VB stored by 4 bytes so approx. +/- 2 billion 2 - 4 Long Integer In Access stored by 4 bytes so approx. +/- 2 billion. In VB stored by 8 bytes so approx. +/– 9.2...E+18. 4 – 8 Boolean (Y/N True/False) Often 1 byte is reserved

26 2609/06/2016 Plenary What is meant by an ASCII character?

27 2709/06/2016 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 2809/06/2016 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.

29 2909/06/2016 Plenary Convert 101 (denary) to binary.

30 3009/06/2016 Plenary 01100101

31 3109/06/2016 Plenary Convert 10011111 to denary.

32 3209/06/2016 Plenary 159


Download ppt "09/06/20161 1.1 Data Representation ASCII, Binary Denary Conversion, Integer & Boolean data types."

Similar presentations


Ads by Google