Codes (Updated)
Codes (Updated)
Codes (Updated)
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
• 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.
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
• 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
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
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
• 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 :
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 :
• 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