Codes (Updated)

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 59

Code

Codes
• A code is a symbolic way to represent an information. In qualitative
inquiry, a code is most often a word or short phrase symbolically
assigns as summative, salient, essence-language-based or visual data.
Decimal System
• Conventional number system

• Ten Symbols:
• 0,1,2,3,4,5,6,7,8,9
Positional Notation
• Positions of the digits indicate the place value. Each place value is of
the power of 10

• For 3,40510 is a decimal number

• 3 – thousands digit (3 x 103)


• 4 – hundreds digit (4 x 102)
• 0 – tens digit (0 x 101)
• 5 – units digit (5 x 100)
Binary Code
• Binary is a base-2 number system representing numbers using a
pattern of ones and zeroes.
• Early computer systems had mechanical switches that turned on to
represent 1, and turned off to represent 0.
• A digital one or zero is simply an electrical signal that's either turned
on or turned off inside of a hardware device
• Binary numbers consist of a series of eight "bits," which are known as
a "byte." A bit is a single one or zero that makes up the 8 bit binary
number.
Positional Notation
• Positions of the digits indicate the place value. Each place value is of the
power of 2

• For 10102 is a binary number

• 1 : (1 x 23) = 8
• 0 : (0 x 22) = 0
• 1 : (0 x 21) = 2
• 0 : (0 x 20) = 0
= 8 + 0 + 2 + 0 = 1010 is the decimal number
Converting Decimal to Binary and vice versa
• Binary to decimal

1 0 0 12
1 0 0 1
1(23) 0(22) 0(21) 1(20)
8 + 0 + 0 + 1 = 910
Converting Decimal to Binary and vice versa
• Decimal to binary
2510

25/2 = 12 r. 1 110012
12/2 = 6 r. 0
6/2 = 3 r. 0
3/2 = 1 r. 1
½=0 r. 1
Bit and Bytes
• Bits are the smallest unit of storage. These store only 1 or 0.

• Bytes are groups of 8 bits

Example:

100010002

There are 256 possible outcomes. Range from 0 to 255 or -128 to 127
10001000
Low - order bit
High - order bit
Integers in Computers
• Data represented by real numbers with no fractional part

• For signed, there are positive and negative numbers. Example for 1
byte it ranges from -128 to 127

• For unsigned, there are only positive numbers. Example for 1 byte, it
ranges from 0 to 255
Boolean Logic
• A branch of algebra that will lead to exactly two results( true or false )

• Boolean Operators
• And - used to confirm that two or more Boolean expressions are all true
• Or - checks that either one condition or another is true.
• Not - only takes one argument and negates it
AND
OR
NOT
Computer Addition
• Be guided with these
three statements:

• 0+0=0

• 0+1=1

• 1 + 1 = 10
But in binary 1 + 1 = 10
110012 + 101112
Carry 1 1 1 1
1 1 0 0 1
+ 1 0 1 1 1
1 1 0 0 0 0

1+1+1
10 + 1
11

1100002
• 11012 + 10112
• 2410 + 510  binary
• 110001012 + 10001002  decimal
• 10002 + 100010 in binary
Text data
• Texts and symbols presented in computer screen are transmitted in
binary codes

• The codes are converted into texts and symbols by means of standard

• American Standard Code for Information Interchange(ASCII) code is a


7 bit system(currently 8 bit) standard for numerical transportation for
characters
Example
• Apple  binary
 01000001 01110000 01110000 01101100 01100101

• Hello, World! binary


 01001000 01100101 01101100 01101100 01101111
00101100 00100000 01010111 01101111 01110010
01101100 01100100 00100001
Hexadecimal Number System
• A number system with a base of 16.

• Symbols:
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F
Octal Number System
• A number system with a base of 8.

• Symbols:
0, 1, 2, 3, 4, 5, 6, 7
Conversion
• Binary to hexadecimal

100010102

1000 1010  group each in 4 bits starting from the low-order bit
10002  810 10102  1010

= (810) (1010)  8A16


• Hexadecimal to binary

2516

(2) (5)  Separate each digits and convert each to decimal then to binary

0010 01012
• Binary to octal

100010102

010 001 010  group each in 3 bits starting from the low-order bit
0102  210 0012  110 0102  210

= (210)(110)(210)  2128
• Octal to binary

178
(110) (710)  0012 1112  11112
Convert the following Hexadecimal into its
ASCII equivalent characters
• 49 66 20 77 65 20 68 61 76 65 20 61 20 71 75 69 7A 2C 20 65 76 65 72
79 62 6F 64 79 20 69 73 20 72 65 71 75 69 72 65 64 20 74 6F 20 62 72
69 6E 67 20 74 68 65 20 41 53 43 49 49 20 74 61 62 6C 65 2E 20 49 74
20 69 73 20 72 65 71 75 69 72 65 64 2E

If we have a quiz, everybody is required to bring the ASCII table. It is


required.
Convert the following Octal into its ASCII
equivalent characters
• 124 150 145 040 101 123 103 111 111 040 164 141 142 154 145 163
040 141 162 145 040 141 154 162 145 141 144 171 040 160 162 157
166 151 144 145 144 040 142 171 040 164 150 145 040 151 156 164
145 162 156 145 164 040 141 156 144 040 142 171 040 164 150 151
163 040 160 162 145 163 145 156 164 141 164 151 157 156 056

The ASCII tables are already provided by the internet and by this
presentation.
Errors and Error Correction
• The error simply means any flaw or deviation that occurs while the
information is transmitted from the source to the destination in a
computer network.

• the deviated bits sequence needs to be replaced with the right bit
sequence so that the receiver can accept the data and process it. This
method is called Error Correction.
Types of Error
• Single Bit Error - Typically, only one bit of the frame received is
corrupt, and the corrupted bit can be located anywhere in the frame.

• Multiple Bit Error - More than one bit received in the frame is found
to be corrupted. Refer to the below image for the multiple-bit error

• Burst Error - More than one consecutive bit is corrupted in the


received frame.
Single Bit Error
Multiple Bit Error
Burst Error
Types of Error Correction
• Forward Error Correction: In this Error Correction Scenario, the
receiving end is responsible for correcting the network error. There is
no need for retransmission of the data from the sender’s side.
• Backward Error Correction: Backward Error Correction means that the
receiver needs to correct the error either by transmitting the corrupted
message or retransmitting the entire message to the destination.
• Hamming Code Error Correction: extra parity bits are appended to the
message which are used by the receiver to correct the single bit error
and multiple bit error.
Error Detecting Codes
• used to detect the errors present in the received data bitstream.
These codes contain some bits, which are included appended to the
original bit stream. These codes detect the error, if it is occurred
during transmission of the original data bitstream.
Parity Code
• Even Parity Code
• The value of even parity bit should be zero, if even number of
ones present in the binary code. Otherwise, it should be one.
So that, even number of ones present in even parity code.

• Odd Parity Code


• The value of odd parity bit should be zero, if odd number of
ones present in the binary code. Otherwise, it should be one.
So that, odd number of ones present in odd parity code.
Even Parity Code
Binary Code Parity Bit Parity Code
000 0 0000
001 1 0011
010 1 0101
011 0 0110
100 1 1001
101 0 1010
110 0 1100
111 1 1111
Even Parity Code
• If the other system receives one of these even parity
codes, then there is no error in the received data. The
bits other than even parity bit are same as that of
binary code.
• If the other system receives other than even parity
codes, then there will be an errors𝑠 in the received data.
In this case, we can’t predict the original binary code
because we don’t know the bit positions𝑠 of error.
Odd Parity Code
Binary Code Parity Bit Parity Code
000 1 0001
001 0 0010
010 0 0100
011 1 0111
100 0 1000
101 1 1011
110 1 1101
111 0 1110
Odd Parity Code
• If the other system receives one of these odd parity
codes, then there is no error in the received data. The
bits other than odd parity bit are same as that of binary
code.
• If the other system receives other than odd parity
codes, then there is an errors𝑠 in the received data. In
this case, we can’t predict the original binary code
because we don’t know the bit positions𝑠 of error.
Note
• Parity bit is only useful for single bit error as a multiple bit error
present a difficulty in determining a original number of bits.
Hamming Code
• Hamming code is useful for both detection and correction of
error present in the received data. This code uses multiple
parity bits and we have to place these parity bits in the
positions of powers of 2.
• The minimum value of 'k' for which the following relation is
correct valid is nothing but the required number of parity bits.

n = number of bits k = number of parity bits


The total number of bits in Hamming code is n + k
Parity bits
• For a 4 bit system, the hamming code would be b7 b6 b5 b4 b3 b2 b1
• The position of the parity bits will be located at b1 ,b2 and b4. The
positions are in power of 2: 20, 21 and 22.
7 6 5 4 3 2 1
• b1 : 7 6 5 4 3 2 1

• b2 : 7 6 5 4 3 2 1

• b4 :
Example:
• Hamming Code for: 10002. Consider even parity code.

b7 b6 b5 b4 b3 b2 b1
1 0 0 b4 0 b2 b1
• b1 : 1 0 0 b4 0 b2 b1

1 0 0 b4 0 b2 b1
• b2 :
1 0 0 b4 0 b2 b1
• b4 :

• b1 : 100 for even parity: add b1 = 1


• b2 : 100 for even parity: add b2 = 1
• b4 : 100 for even parity: add b4 = 1
• Hamming Code: 10010112
Example:
• Hamming Code for: 11012. Consider even parity code.

b7 b6 b5 b4 b3 b2 b1
1 1 0 b4 1 b2 b1
• b1 : 1 1 0 b4 1 b2 b1

1 1 0 b4 1 b2 b1
• b2 :
1 1 0 b4 1 b2 b1
• b4 :

• b1 : 101 for even parity: add b1 = 0


• b2 : 111 for even parity: add b2 = 1
• b4 : 110 for even parity: add b4 = 0
• Hamming Code: 11001102
More Examples

• Answer: 111012
• 258
• Convert 10010 to base 7
• Convert 1002 to base 5
• Hamming Code for 1011001. Assume even parity
For R1:
11101(R1)
For even parity, number of ones
should be even numbered: R1 = 0

For R2:
10101(R2)
For even parity, number of ones
should be even numbered: R2 = 1
For R4:
100(R4)
For even parity, number of ones
should be even numbered: R4 = 1

For R8:
101(R8)
For even parity, number of ones
should be even numbered: R8 = 0

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy