Professional Documents
Culture Documents
ch2 - Acquiring Numeric and Textual Data
ch2 - Acquiring Numeric and Textual Data
and
Textual Data
Contents
Data Acquisition – Input Units
Representation of Numeric Data
Binary Encoding
Number Systems
Internal representation
Binary numbers
Binary digits (bits)
1 byte = 8 bits
1 nibble = 4 bits
2 bits
00 01 10 11
3 bits
000 001 010 011
100 101 110 111
4 bits
0000 0001 0010 0011 0100 0101 0110 0111
1111 1000 1001 1010 1011 1100 1101 1110
Binary encoding …
0 1 2 3 4 5 6 7 8 9
0000 0001 0010 0011 0100 0101 0110 0111 1000 1001
57267
01010111001001100111
Drawback
Not suitable for arithmetic calculations
Number systems
Decimal : 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20
Binary : 0, 1, 10, 11, 100, 101, 110, 111, 1000, 1001, 1010, 1011, 1100, 1101,
1110, 1111, 10000, 10001, …
Hexadecimal : 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F, 10, 11, 12, … 19, 1A,
1B, …
Powers of two
1 0 0 1 0 1 0 1
27 26 25 24 23 22 21 20
128 64 32 16 8 4 2 1
128 0 0 16 0 4 0 1
100101012 = 14910
Representation of fractions
Decimal Number System
1 1 1 0 1 1 1 0 1
25 24 23 22 21 20 2-1 2-2 2-3
32 16 8 4 2 1 0.5 0.25 0.125
32 16 8 0 2 1 0.5 0 0.125
59.625
Convert 11000.00112 to decimal
1 1 0 0 0 0 0 1 1
24 23 22 21 20 2-1 2-2 2-3 2-4
16 8 4 2 1 0.5 0.25 0.125 0.0625
16 8 0 0 0 0 0 0.125 0.0625
24.1875
Decimal to binary conversion
Convert 2910 to binary
2 29
2 14 1
2 7 0
2 3 1
2 1 1
2910 = 111012
Convert 39510 to binary
2 395
2 197 1
2 98 1
2 49 0
2 24 1
2 12 0
2 6 0
2 3 0
2 1 1
39510 = 1100010112
Conversion of decimal fractions to binary
Convert 0.812510 to binary
0.8125 x 2 1.625 1
0.625 x 2 1.25 1
0.25 x 2 0.5 0
0.5 x 2 1.0 1
0.812510 = (0.1101)2
Convert 0.562510 to binary
0.5625 x 2 1.125 1
0.125 x 2 0.25 0
0.25 x 2 0.5 0
0.5 x 2 1.0 1
0.812510 = (0.1001)2
Convert 0.310 to binary
0.3 x 2 0.6 0
0.6 x 2 1.2 1
0.2 x 2 0.4 0
0.4 x 2 0.8 0
0.8 x 2 1.6 1
0.6 x 2 1.2 1
0.310 = 0.010012
A leather belt costs Rs. 136.75. What is the binary equivalent of this value
when it is stored in the computer?
2 136
2 68 0
2 34 0 0.75 * 2 = 1.5
2 17 0 0.5 * 2 = 1.0
2 8 1
2 4 0 Answer : 10001000.11
2 2 0
2 1 0
The item code for a variety of brinjal is 6367. It costs Rs. 75.67 a kilo.
Represent the item code using binary encoding and the cost in binary
number system.
Item code : 6367
Binary code : 0110001101100111
Cost per kg : 75.67
Binary equivalent : 1001011.101010
2 75 0.67 * 2 = 1.34
2 37 1 0.34 * 2 = 0.68
2 18 1 0.68 * 2 = 1.36
2 9 0 0.36 * 2 = 0.72
2 4 1 0.72 * 2 = 1.44
0.44 * 2 = 0.88
2 2 0
0.88 * 2 = 1.76
2 1 0
0.76 * 2 = 1.52
0.52 * 2 = 1.04
0.04 * 2 = 0.08
Hexadecimal to Decimal Conversion
D 6 C 1
163 162 161 160
4096 256 16 1
13 x 4096 6 x 256 12 x 16 1x1
53248 1536 192 1
D6C116 = 5497710
Hexadecimal to Decimal Conversion
F 9 A . B C 3
162 161 160 . 16-1 16-2 16-3
256 16 1 . 1/16 1/256 1/4096
15 x 256 9 x 16 10 x 1 . 11/16 12/256 3/4096
3840 144 10 . 0.6875 0.0468 0.000732
F9A.BC316 = 3994.73510
Hexadecimal representation
Character Set
Set of valid characters in a programming language
Processing of characters
Identifying vowels
Counting the number of vowels
Sorting in alphabetical order
Encoding
Representing a character using a unique string of bits
English alphabets : 26
Number of bits required : 5 (25 = 32)
ISCII
Indian Standard Code for Information Interchange
8 bits
Unicode
16 bits
Least Significant bits Most Significant Bits
b 3 b2 b1 b0 b6 b5 b 4
The license number of a car is TN74C5425. Represent it using 7-bit ASCII code.
101010010011100110111011010010000110110101011010001100100110101
Error detecting codes
Errors may occur in recording data on magnetic surfaces due to bad spots in the surface
Errors may also be caused by electrical disturbances during data transmission between
units.
Parity check bit – Detects single bit errors
Odd parity check bits and Even parity check bits
Parity check bit is appended to the 7 bit code in such a way that the total number of 1s in
each character code is even. (Even)
Ex.
E – 1000101 - 10001011
A – 1000001 - 10000010