# What is bit in simple computer language

## 3.4 Texts with zeros and ones

### 3. Zeros and ones

In the introduction there was such a strange suggestion that all the great things that you might have already done with your computer, such as painting pictures, writing texts, etc., are nothing more than calculating with zeros and ones for the computer.

In the previous chapters we have already seen how the computer represents numbers with zeros and ones (see Table 2 to Table 5). A certain number is assigned to a certain bit sequence - naturally in such a way that it also makes mathematical sense, namely in the same way as we count in the decimal system.

Nobody prevents us from assigning a letter to a bit sequence instead of a number, does it? Why shouldn't 01000001 mean "A" instead of "65"?

Let us look again at the addition (the plus calculation) that our super-simple computer carried out in Section 3.1: The result, i.e. which lamp came on when, only depended on how the switches were set, i.e. which ones Input we made, and how our computer was wired - you could also say programmed - was. For the circuit, it didn't matter what meaning we assigned the switch positions or the lighting of the lamp (s); it conducted the current as the wiring was. It was only we who made the wiring exactly so that the meaning of our result matched the meaning of our input! That sounds like cheating now, but it's not! This is exactly how a real computer works!

We can now come up with a simple task for editing texts, for example we could want to turn a capital letter into a small letter and vice versa. So that our computer can do this, we only have to determine which bit pattern corresponds to which letter, and then we have to think about a wiring that generates the corresponding bit pattern of the lower case letter on the output side (lamps) for each capital letter bit pattern on the input side (switch), or vice versa.

It's easier than it sounds!

Let's start with the definition of the letters: If we stick to the eight bits that the inventors of the computer agreed on at some point, then we can represent 256 different characters. The alphabet has 26 letters; they are available in large and small letters, that makes 52 pieces together. Then there are the umlauts ä, ö and ü in large and small as well as the "ß". We'll probably also want to write whole sentences with our computer one day; for this we also need punctuation marks such as full stop, comma, exclamation mark, etc. and at some point we will certainly find it great to be able to use strange characters like%, , \$, &. In addition, there are certainly computer fans in other countries who need other special characters. But for the beginning, 256 characters will be enough for us!

It makes sense that all computers use the same assignment of letters to bit sequences, because otherwise a text written on one computer would have a completely different meaning on another computer and this sentence might look like this:

Kl43jsdc l rlk 2ehr Es'fhg e4 \$ "öoijh rfghElSöfdh verjhgo i reobjGRnSh oer ergPner oer rönkFGbjs.renor ihg9h 25QQnön548p 5gi uARsfd

To prevent that from happening, it was agreed on the common definition in Table 6, which one ASCII named.
ASCII is an abbreviation and means "American Standard Code for Information Interchange". This is English and means in German: American standard code for the exchange of information. Although the name says "American", it is used all over the world.

A code is a Assignment from character to other characters or to a specific meaning.

 0 0000 32 100000 33 100001 ! 34 100010 " 35 100011 # 36 100100 \$ 37 100101 % 38 100110 & 39 100111 ' 40 101000 ( 41 101001 ) 42 101010 * 43 101011 + 44 101100 , 45 101101 - 46 101110 . 47 101111 / 48 110000 0 49 110001 1 50 110010 2 51 110011 3 52 110100 4 53 110101 5 54 110110 6 55 110111 7 56 111000 8 57 111001 9 58 111010 : 59 111011 ; 60 111100 61 111101 = 62 111110 > 63 111111 ? 64 1000000 @ 65 1000001 A. 66 1000010 B. 67 1000011 C. 68 1000100 D. 69 1000101 E. 70 1000110 F. 71 1000111 G 72 1001000 H 73 1001001 I. 74 1001010 J 75 1001011 K 76 1001100 L. 77 1001101 M. 78 1001110 N 79 1001111 O 80 1010000 P. 81 1010001 Q 82 1010010 R. 83 1010011 S. 84 1010100 T 85 1010101 U 86 1010110 V. 87 1010111 W. 88 1011000 X 89 1011001 Y 90 1011010 Z 91 1011011 [ 92 1011100 \ 93 1011101 ] 94 1011110 ^ 95 1011111 _ 96 1100000 ` 97 1100001 a 98 1100010 b 99 1100011 c 100 1100100 d 101 1100101 e 102 1100110 f 103 1100111 G 104 1101000 H 105 1101001 i 106 1101010 j 107 1101011 k 108 1101100 l 109 1101101 m 110 1101110 n 111 1101111 O 112 1110000 p 113 1110001 q 114 1110010 r 115 1110011 s 116 1110100 t 117 1110101 u 118 1110110 v 119 1110111 w 120 1111000 x 121 1111001 y 122 1111010 z 123 1111011 { 124 1111100 | 125 1111101 } 126 1111110 ~ 161 10100001 � 162 10100010 � 163 10100011 � 164 10100100 � 165 10100101 � 166 10100110 � 167 10100111 � 168 10101000 � 169 10101001 � 170 10101010 � 171 10101011 � 172 10101100 � 173 10101101 � 174 10101110 � 175 10101111 � 176 10110000 � 177 10110001 � 178 10110010 ² 179 10110011 ³ 180 10110100 � 181 10110101 µ 182 10110110 � 183 10110111 � 184 10111000 � 185 10111001 � 186 10111010 � 187 10111011 � 188 10111100 � 189 10111101 � 190 10111110 � 191 10111111 � 192 11000000 À 193 11000001 Á 194 11000010 Â 195 11000011 � 196 11000100 Ä 197 11000101 � 198 11000110 � 199 11000111 � 200 11001000 È 201 11001001 É 202 11001010 Ê 203 11001011 � 204 11001100 Ì 205 11001101 Í 206 11001110 Î 207 11001111 � 208 11010000 � 209 11010001 � 210 11010010 O 211 11010011 O 212 11010100 O 213 11010101 � 214 11010110 Ö 215 11010111 � 216 11011000 � 217 11011001 Ù 218 11011010 Ú 219 11011011 Û 220 11011100 Ü 221 11011101 � 222 11011110 � 223 11011111 ß 224 11100000 à 225 11100001 á 226 11100010 â 227 11100011 � 228 11100100 Ä 229 11100101 � 230 11100110 � 231 11100111 � 232 11101000 è 233 11101001 é 234 11101010 ê 235 11101011 � 236 11101100 ì 237 11101101 í 238 11101110 î 239 11101111 � 240 11110000 � 241 11110001 � 242 11110010 O 243 11110011 O 244 11110100 O 245 11110101 � 246 11110110 ö 247 11110111 � 248 11111000 � 249 11111001 ù 250 11111010 ú 251 11111011 û 252 11111100 ü 253 11111101 � 254 11111110 � 255 11111111 �

Table 6: The ASCII code

Don't let the table confuse you! Three columns, separated by a space, belong together: on the left is the decimal number, then the bit pattern of eight bits that corresponds to this number comes, and in the third column is the letter or character that has been assigned to the bit pattern .

You can find our letters A to Z and a to z in the area with a blue background.

If you look carefully, you will notice that not all 256 possible bit patterns are shown in the table (e.g. 1 to 31 are not). This is because they are filled with something that cannot be printed, such as characters that tell a printer to take a new sheet or start a new line. Something like that is called Control characters.

The character assigned to zero and the character for 32 look the same in the table, but they are not: The zero really means Nothing, and 32 is the code for a space.

You may notice something else strange about the table: It also contains bit sequences to which the digits 0 to 9 are assigned. You are in the area with a yellow background.
What do we need that for? We already represented numbers with zeros and ones in chapter 3.2! Why are we doing this again here, and with a different assignment than we had before? The "9" in the ASCII table is "00111001" and not "00001001" as we would have written it when calculating! Now the answer is this: Even when writing a text we want to be able to write our digits; Only in this paragraph, which you have just read, do the digits 0, 1, 2, 3 and 9 appear, but we do not want to calculate with them in the real sense. After all, the people who came up with the ASCII table were so smart that the right half (the right nibble) of the bytes used to represent digits is identical to the mathematical coding of the numbers: the right four bits of ASCII Codes for the 9 are called 1001 and that corresponds exactly to the pattern that results when we count to nine with zeros and ones. Written in hexadecimal (see chapter 3.3!) Is the ASCII code for the digits 0 to 9: 0x30, 0x31, 0x32, ..., 0x39; the right digit of the hexadecimal number therefore always corresponds to the digit shown.

Back to our task: Our computer is to convert the bit pattern of an upper case letter into the bit pattern of a lower case letter. Here, too, it is worth taking a closer look: Uppercase and lowercase letters are identical in their bit pattern, except in the sixth position from the right! Upper case letters have a zero, lower case letters have a one.

The computer that can cope with our task only has to transfer the bit pattern from our eight input switches to the output lamps. Lamp number six must light up if there is a 0 on the input page and must be switched off if there is a 1 there.

Figure 9 shows a computer that can do this. The conversion from "M" to "m" is shown. (Find the bit pattern for m and for M in Table 6!)

 Figure 9: Computer that converts from upper case to lower case and vice versa

Note:

The switch for bit no. 6 (arrow) is in the "zero" position, ie up. Nevertheless, he conducts the electricity. If we were to convert from "m" to "M", we would have to push this switch down to position "one"; in this position the cable would be interrupted so that a zero appears on the output side. The bit is said to be inverted, i.e. reversed: The opposite of the input (switch) is always at the output (lamp).

A second special feature: Our computer would actually only need six switches and six lamps for this task, because bits number 7 and number 8 are always set to zero and one for both uppercase and lowercase letters (see Table 6). If you were to actually use our computer and enter letter codes with the switches, you might find that you never had to turn those two switches.

And indeed: old teleprinters, devices that used to be used to transmit texts over a telephone line, only worked with five bits: They did not differentiate between upper and lower case and could display 32 different characters with five bits. These devices are no longer needed today; the fax has completely superseded them!

Our computer for converting from upper to lower case and vice versa works in any case!

That was pretty much theory now and you probably don't even think that something like this works in a real computer. If you have a PC, you can try it out right away! Let someone help you if the instructions aren't clear to you, or read on first; everything that seems strange to you and you don't understand will be explained later!

Experiment 1:
ASCII codes are hidden in the PC!

Where which button is located is shown in Figure 10!

 Start your computerStart any program in which you can enter something with the keyboard, e.g. Word, Excel, Notepad, etc.The left of the three lights above the numeric keypad must light up; then you can use the numeric keypad to type in numbers. If this is not the case yet, press the NumLock key!Press and hold the Alt key.Now type a three-digit ASCII cade from Table 6 on the numeric keypad. For example, for an "M" you type "077", for a curly bracket "{" you type "123" or for the at sign "@" you type "064".Release the Alt key again! The sign appears!
 Figure 10: PC keyboard

If you use ASCII codes greater than 127 in this attempt, you may see different characters than those shown in Table 6. The reason for this is that there are different versions of this upper half of the table (code number 128 to 255), because the 255 possible characters were not enough and you can change this part of the assignments.

What does this experiment show us? Now: The computer interprets your number entry according to the assignment shown in Table 6. So it was programmed into him. In the past, this method was used with the Alt key to enter characters into the computer that were not on the keyboard. Today almost every program offers a more convenient way to enter such special characters.

But at least you are now sure that your computer correctly understands our assignment of letters and characters to zeros and ones!

Another small note: Although you enter the same numbers with the numeric keypad as with the other number keys, your computer distinguishes these keys! You can tell by the fact that the experiment with the other number keys does not work!