Download presentation
1
Lesson 2 0x Coding ASCII Code
2
Number Systems Coding Decimal number system Binary number system
Octal number system Hexadecimal number system Conversion ASCII Code
3
Coding Computer Keyboard Screen Scanner Decoding Coding Printer Mouse
Microphone All Information are converted into codes to be processed by the computer. The codes are numbers in the Binary System (1s & 0s) Why Binary ? ASCII Code
4
Decimal Number System This is the used number system in our life calculations. It contains 10 symbols to represent the numbers which are {0,1,2,3,4,5,6,7,8,9}, any number in the system can be represented in away that it depends on the power of 10. ASCII Code
5
Decimal (base 10) Examples: 2434=2000+400+30+4
=2x x x10 + 4x1 =2x x102 +3x x100 Example 2: 1479 = 1 * * * * 100 ASCII Code
6
Binary Number system This number system contains only two symbols to represent its numbers, which are {0 and 1} only. e.g.: 100, are accepted numbers in the binary system where is not accepted because it contains the symbol (2) which is not included in the set of symbols. In order to distinguish the numbers in the binary system from the decimal system, they are put in parenthesis and the number 2 is put to the bottom right of the brackets as a subscript; like (1001)2 for the binary system , and the number 10 is put to for the decimal system ; like (1001)10. ASCII Code
7
Conversion from Binary to Decimal
1 1 1 Example: (1101) 2 = 8x1 + 4x1 + 2x0 +1x1 = (13) 10 1 (100)2= 1x22 + 0x21 + 0x 20 =1x4 + 0x2 + 0x1 = = (4)10 ASCII Code
8
Conversion from Binary to Decimal
1 1 1 (1011)2=1x23 + 0x22 + 1x x 20 =1x 8 + 0x4 + 1 x x 1 = =(11)10 Exercise: What are the decimal values for the following binary numbers: a- (10010)2 b- ( )2 c- ( )2 ASCII Code
9
Conversion from Binary to Decimal
Rule: If the binary number consists of only ones, you can find its decimal equivalent number using this formula: Decimal = 2n – 1 Where n is the number of bits, for example 1111 has 4 bits. Example 1: ( )2 has 8 bits, so Decimal = 28 – 1 = 255 Example 2: ( )2 has 9 bits, so Decimal = 29 – 1 = 511 Binary Decimal 1 11 3 111 7 1111 15 11111 31 111111 63 127 255 511 1023 2024 ASCII Code
10
Conversion from Binary to Decimal fraction
2-1 2-2 2-3 2-4 0.5 0.25 0.125 0.0625 Examples Convert binary to decimal: 1) 2) ( )2 ( )2 Sol. Sol. = = (6.125) = =(46.625)10 ASCII Code
11
Decimal to binary conversion
Example: 43 43 ÷ 2: Quotient 21, remainder 1: Result > 1 21 ÷ 2: Quotient 10, remainder 1: Result > 1 1 10 ÷ 2: Quotient 5, remainder 0: Result > 0 1 1 5 ÷ 2: Quotient 2, remainder 1: Result > 2 ÷ 2: Quotient 1, remainder 0: Result > 1 ÷ 2: Quotient 0, remainder 1: Result > Exercise: Convert the following decimal numbers to binary 22 63 174 3000 ASCII Code
12
Decimal to binary conversion
8 1000 16 10000 1 9 1001 17 10001 2 10 1010 18 10010 3 11 1011 19 10011 4 100 12 1100 20 10100 5 101 13 1101 21 10101 6 110 14 1110 22 10110 7 111 15 1111 : ASCII Code
13
Fractions conversion from decimal to binary
ASCII Code
14
Fractions conversion from decimal to binary
ASCII Code
15
Count… ASCII Code
16
Count… Exercise: convert the following decimal numbers to binary:
a- (85) b- (117) c- (43.75) d- ( ) e- (36.045) 2- Arrange the following binary numbers in ascending order a b c d ASCII Code
17
Octal Number system This system contains 8 digits (symbols) which are the first 8 decimal digits (0,1,2,3,4,5,6,7); (there are no 8 & 9 in the octal number system). Valid numbers in octal system: Invalid numbers in octal system: Numbers are presented in this systems in parentheses with subscript 8 to separate them among other number system e.g. (45612)8 ASCII Code
18
Octal Number (base 8) Example: convert (3057)8 to decimal.
Sol =3x83+0x82+5x81+7x80 =3x512+0x64+5x8+7x1 = =1583 then (3057)8 is equivalent to (1583)10 ASCII Code
19
Decimal to octal conversion
Example 1: (173)8 Sol. Remainder 21 8 5 2 8 2 The result is ( 25 5)8 ASCII Code
20
Example 2: (1583)10 Sol. Remainder 1583. 8. 197. 8. 7. 24. 8. 5. 3. 8
Example 2: (1583)10 Sol. Remainder The result is ( 3057)8 Example 2: (1583)10 Sol. Remainder The result is ( 3057)8 ASCII Code
21
Converting decimal fractions to octal
This can be obtained by multiply the decimal fraction by 8 and watch the carry into integer’s position. Example: (0.23) x 8 = x 8 = x 8 = ∴ (0.23)10 ≡ (0.165)8 ASCII Code
22
Octal to binary conversion
Because 8 = 23 , we can convert from octal to binary directly, that is each digit in octal will match 3 digits in binary as follows: ASCII Code
23
CONT… ASCII Code
24
Binary to octal conversion
Binary to octal conversion: this conversion can be obtained as an opposite to the conversion from octal to binary that is grouping the binary number into threes, and converting them to octal ones. Examples: convert from binary to octal. Answer: ∴( )2≡ (715)8 ASCII Code
25
Hexadecimal Number system
This system contains sixteen symbols to represent its numbers, Which are: {0,1, 2, 3 ,4,5,6,7,8,9,A,B,C,D,E,F} Where A represent the value (10)10, B represent (11)10, C represent (12)10, D represent (13)10, E represent (14)10, F represent (15)10. ASCII Code
26
Cont…. Valid numbers in hexadecimal numbers: 78A 100 A4BB To distinguish hexadecimal number from other systems, we put the hexadecimal numbers between two parenthesis like (49B3)16. The weights of the numbers in hexadecimal number system are evaluated according to the positional number system: ASCII Code
27
Converting from hexadecimal to decimal:
Examples: (34)16 Solution: 3x x160 =3x16 + 4x1 =48+4 =(52)10 (34)16 (52)10 (40AC)16 Solution: 4 x x Ax161 + Cx160 =4 x x x x 1 = =(16556)10 (40AC)16 (16556)10 ASCII Code
28
Converting from decimal to hexadecimal:
ASCII Code
29
Converting from hexadecimal to Binary:
because 16=24 then a hexadecimal number can be converted directly to 4 binary digits ass follows:
30
Converting from hexadecimal to Binary:
ASCII Code
31
Converting from Binary to hexadecimal:
we group each 4 numbers to convert them into one hexadecimal number. ASCII Code
32
Conversion Diagram Octal(8) Decimal(10) Binary(2) Hex(16)
by the Base and take the reminder Use the table directly Decimal(10) Binary(2) By the Weight and take the Sum Hex(16) ASCII Code
33
ASCII Code ASCII stands for American Standard Code for Information Interchange. The ASCII is a 7 bits code whose format is X6X5X4X3X2X1X0, where each X is 0 or 1. The ASCII code is used to represent the English language characters (letters, numbers, symbols and punctuations) by binary numbers to used in computers. ASCII Code
34
Cont.... ASCII Code Notes: In computer processing the “space” is a significant character, where the ASCII code of the space is Upper case and lower case letters have different values in ASCII code. For example the ASCII code for A is and the ASCII code for a is ASCII Code
35
Ascii Code ASCII Code
36
Write Print S in ASCII code.
Example: Write Print S in ASCII code. P( ) r( ) i( ) n( ) t( ) space( ) S( ) ASCII Code
37
Parity Bit Note: Read page number 122 from the book. The parity bit is an additional bit added to the ASCII code to catch errors in transmitting data. So, the message format for each character (ASCII code with parity bit) is X7X6X5X4X3X2X1X0 ASCII Parity ِbit ASCII Code
38
Types of Parity Bit: Odd Parity Bit: in this type number of ones in the message for each character (ASCII code and parity bit) must be odd. Even Parity Bit: in this type number of ones in the message for each character (ASCII code and parity bit) must be even. ASCII Code
39
Suppose that two devices are communicating with even parity.
The transmitting device (Sender) sends data, it counts the number of ones in each group of seven bits. If number of ones is even, it sets the parity bit to 0; if the number of ones is odd, it sets the parity bit to 1. In this way, every message has an even number of ones. ASCII Code
40
Cont... Parity Bit On the receiving side, the device checks each message to make sure that it has an even number of ones. If the receiving device finds an odd number of ones, the receiver knows there was an error during transmission. ASCII Code
41
Binary Coded Decimal(BCD):
a format for representing decimal numbers (integers) in which each digit is represented by four bits . For example, the number 375 would be represented as: ASCII Code
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.