Design  | SFC  |  NOS  |  Code |  Diary  | WWW |  Essay |  Cisco | [Home]

Essays

# Red flag, green flag (Learning Binary)

Work in progress, 3 July 2001.

magine that you are an army scout who's job it is to sit on a hill and watch for an attacking army. You have been given a red flag and a green flag, from which you could represent two different conditions. A green flag could represent that there were no armies approaching, and a red flag would represent that there was an army advancing on the city. Thus:

 Red flag - Approaching army. Green flag - No approaching army.

Now, this does not give much information on the size of the army, at all, or if the approaching army is an aggressive one or a friendly one. Thus if we used two flags we could represent four different conditions:

 Red flag, red flag - approaching large aggressive army. Get troops ready for battle. Red flag, green flag - approaching small aggressive army. Put troops on standby. Green flag, red flag - approaching friendly army. Setup greeting parade. Green flag, green flag - no approaching army.

It can be seen that the flag on the left-hand side is more significant that the flag at the right-hand side, as this flag represents that there is an aggressive army approaching. This flag would be seen as the most-significant flag. Now let us represent the flags with either R (for red), and G (for green). Thus the states now become:

 RR - approaching large aggressive army. Get troops ready for battle. RG - approaching small aggressive army. Put troops on standby. GR - approaching friendly army. Setup greeting parade. GG - no approaching army.

The number of flags that we have thus determines the number of conditions that we can represent. If we only have one color of flag, then we can only represent two states with one flag, four states with two flags, eight states with three flags (RRR, RRG, RGR, RGG, . GGR and GGG), and so on. This type of representation with two conditions for each representation is known as binary. In computer systems the conditions for each representation is a '0' and a '1' (or sometimes as TRUE or FALSE). Thus, in binary, we could represent the red flag with a '1', and the green flag with a '0'. Our conditions (or states) are now: 00 (no approaching army); 01 (approaching friendly army); 10 (approaching small aggressive army); and 11 (approaching aggressive army).

A particular problem that we might have when we are signaling the information about the army is when our flags are changing. For example, say that we where currently in the condition of GG, and a large aggressive army started to approach. The scout would then have to change the flags from GG to RR. This will take two changes before he can reflect the new condition. How would he do it? If he changed the most-significant flag first, he would signal that there was an approaching friendly army, and the city would get a greeting parade ready, only then to be told that there was a large aggressive army approaching. This would obviously confuse everyone in the city. If he changed the least significant flag, then the troops would be put on standby, only to be told that they would immediately be put on full alert. The problem we have is that we need some way to change the state of the flags, so that intermediate values are not taken as final values. Thus one way to do this would be to hide the changeover of the flags. This also occurs in a computer system where values of the binary digits changes, and these should not be taken as valid values. This is overcome with clock signals and handshaking lines, which are used to define when the values on the computer's bus are actually valid, or not.

Chapter 2, Mastering Computing, W.Buchanan, Palgrave.

If you've got any comments on this essay (no matter if you agree or disagree with it), please send them to me using the form below.

### Details

 Name (Surname, First Name): [Not required] E-mail: