In: Computer Science
Convert decimal 3,712 and 4,132 to both BCD and ASCII codes. For ASCII, an even parity bit is to be apppended at the left.
(1)
(i) 371210
310 = 0011BCD
710 = 0111BCD
110 = 0001BCD
210 = 0010BCD
Therefore, 3712 in BCD = 0011 0111 0001 0010
(ii)
ASCII Value | Hex Decimal | Decimal | Binary | ASCII CODE (even parity) |
---|---|---|---|---|
3 | 33 | 3x161+3x160 = 51 | 0110011 | 0 0110011 |
7 | 37 | 3x161+7x160 = 55 | 0110111 | 1 0110111 |
1 | 31 | 3x161+1x160 = 49 | 0110001 | 1 0110001 |
2 | 32 | 3x161+2x160 = 50 | 0110010 | 1 0110010 |
Therefore, ASCII Code: 00110011 10110111 10110001 10110010
Note: Bold bits are parity bits.
Method 2: (Shortcut)
To convert to ASCII
Step 1: Add 48 to given character
3 + 48 = 51
7 + 48 = 55
1 + 48 = 49
2 + 48 = 50
step 2: Now convert obtained decimal numbers to binary
51 = 01100112
55 = 01101112
49 = 01100012
50 = 01100102
Step 3:
Even parity means total number 1's should be even. If a number contains odd 1's append 1 to it's left to make it even.
If it contains odd 1's append 0 to it's left.
ASCII code: 00110011 10110111 10110001 10110010
2)
(i) 413210
410 = 0100
110 = 0001
310 = 0011
210 = 0010
BCD : 0100 0001 0011 0010
(ii)
ASCII Value | Hex Decimal | Decimal | Binary | ASCII CODE (even parity) |
---|---|---|---|---|
4 | 34 | 3x161+4x160 = 52 | 0110100 | 1 0110100 |
1 | 31 | 3x161+1x160 = 49 | 0110001 | 1 0110001 |
3 | 33 | 3x161+3x160 = 51 | 0110011 | 0 0110011 |
2 | 32 | 3x161+2x160 = 50 | 0110010 | 1 0110010 |
ASCII Code of 4132 is : 10110100 10110001 00110011 10110010