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.

00000  32100000 33100001!
34100010"35100011#36100100$
37100101%38100110&39100111'
40101000(41101001)42101010*
43101011+44101100,45101101-
46101110.47101111/481100000
491100011501100102511100113
521101004531101015541101106
551101117561110008571110019
58111010:59111011;60111100
61111101=62111110>63111111?
641000000@651000001A.661000010B.
671000011C.681000100D.691000101E.
701000110F.711000111G721001000H
731001001I.741001010J751001011K
761001100L.771001101M.781001110N
791001111O801010000P.811010001Q
821010010R.831010011S.841010100T
851010101U861010110V.871010111W.
881011000X891011001Y901011010Z
911011011[921011100\931011101]
941011110^951011111_961100000`
971100001a981100010b991100011c
1001100100d1011100101e1021100110f
1031100111G1041101000H1051101001i
1061101010j1071101011k1081101100l
1091101101m1101101110n1111101111O
1121110000p1131110001q1141110010r
1151110011s1161110100t1171110101u
1181110110v1191110111w1201111000x
1211111001y1221111010z1231111011{
1241111100|1251111101}1261111110~
161101000011621010001016310100011
164101001001651010010116610100110
167101001111681010100016910101001
170101010101711010101117210101100
173101011011741010111017510101111
176101100001771011000117810110010²
17910110011³1801011010018110110101µ
182101101101831011011118410111000
185101110011861011101018710111011
188101111001891011110119010111110
1911011111119211000000À19311000001Á
19411000010Â1951100001119611000100Ä
197110001011981100011019911000111
20011001000È20111001001É20211001010Ê
2031100101120411001100Ì20511001101Í
20611001110Î2071100111120811010000
2091101000121011010010O21111010011O
21211010100O2131101010121411010110Ö
215110101112161101100021711011001Ù
21811011010Ú21911011011Û22011011100Ü
221110111012221101111022311011111ß
22411100000à22511100001á22611100010â
2271110001122811100100Ä22911100101
230111001102311110011123211101000è
23311101001é23411101010ê23511101011
23611101100ì23711101101í23811101110î
239111011112401111000024111110001
24211110010O24311110011O24411110100O
2451111010124611110110ö24711110111
2481111100024911111001ù25011111010ú
25111111011û25211111100ü25311111101
2541111111025511111111

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!

  1. Start your computer
  2. Start any program in which you can enter something with the keyboard, e.g. Word, Excel, Notepad, etc.
  3. 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!
  4. Press and hold the Alt key.
  5. 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".
  6. 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!