Storing Text using ASCII Assignment
1. Converting keyboard character from decimal to binary
Keyboard character ASCII code (decimal) ASCII code (binary)
Space 32 0010 0000
Comma 44 0010 1100
Full stop 46 0010 1110
0 48 0011 0000
1 49 0010 0001
2 50 0011 0010
3 51 0011 0011
4 52 0011 0100
5 53 0011 0101
6 54 0011 0110
7 55 0011 0111
8 56 0011 1000
9 57 0011 1001
2. Converting name to binary
Thant
Character T h a n t
Decimal 84 104 97 110 116
binary 0101 0100 0110 1000 0110 0001 0110 1110 0111 0100
3. Converting binary to decimal.
1001 1110
128s 64s 32s 16s 8s 4s 2s Units
1 0 0 1 1 1 1 0
1 x 128 = 128
0 x 64 = 0
0 x 32 = 0
1 x 16 = 16
1x8=8
1x4=4
1x2=2
0x1=0
128 + 16 + 8 + 4 + 2 = 158
1001 1110 in binary is 158 in decimal.
0011 0111
128s 64s 32s 16s 8s 4s 2s Units
0 0 1 1 0 1 1 1
0 x 128 = 0
0 x 64 = 0
1 x 32 = 32
1 x 16 = 16
0x8=0
1x4=4
1x2=2
1x1=1
32 + 16 + 4 + 2 + 1 = 55
0011 0111 in binary is 55 in decimal.
4. Converting decimal to binary
240
128s 64s 32s 16s 8s 4s 2s Units
1 1 1 1 0 0 0 0
240 – 128 = 112
112 – 64 = 48
48 – 32 = 16
16 – 16 = 0
240 in decimal is 1111 0000 in binary.
150
128s 64s 32s 16s 8s 4s 2s Units
1 0 0 1 0 1 1 0
150 – 128 = 22
22 – 16 = 6
6–4=2
2–2=0
150 in decimal is 1001 0110 in binary.
68
128s 64s 32s 16s 8s 4s 2s Units
0 1 0 0 0 1 0 0
68 – 64 = 4
4–4=0
68 in decimal is 0100 0100 in binary.
5. Binary addition
1101 0010 + 0111 1100
128s 64s 32s 16s 8s 4s 2s Units
Number 1 1 1 0 1 0 0 1 0
Number 2 0 1 1 1 1 1 0 0
Carry 1 1 1 0 0 0 0 0
Sum 0 1 0 0 1 1 1 0
Sum is 01001110 and carry is 11100000.
In carry of last column, there is value of 1 which means the sum value is more than 255 in 8 digits so it
has overflow error.
0111 1110 + 1010 0100
128s 64s 32s 16s 8s 4s 2s Units
Number 1 0 1 1 1 1 1 1 0
Number 2 1 0 1 0 0 1 0 0
Carry 1 1 1 1 1 0 0 0
Sum 0 0 1 0 0 0 1 0
Sum is 00100010 and carry is 11111000.
In carry of last column, there is value of 1 which means the sum value is more than 255 in 8 digits so it
has overflow error.