# Representation of Data and Instructions

## General

All data and instructions are held in the computer in the form of binary numbers, that is to say, they are represented by groups of 1's and 0's. Although ability in binary arithmetic is not essential to a programmer, an understanding of the notation is reqired, and a brief explanation follows.

Since there exist only the two digits 0 and 1, counting in the binary scale proceeds thus:

 One 1 Two 10 Three 11 Four 100 Five 101 Six 110 Seven 111 Eight 1000

The digits represent, from right to left, the powers of 2, i.e. 1, 2, 4, 8 etc., just as in the decimal scale the positions represent the powers of 10, i.e. 1, 10, 100 etc. The binary number 1101 therefore represents:

1.20 + 0.21 + 1.22 + 1.23 = 1 + 4 + 8 = 13
Similarly, in the representation of fractions, the digits to the right of the binary point represent negative powers of 2, i.e. 1/2, 1/4, 1/8 etc., thus:
 Binary Vulgar Decimal .1 1/2 .5 .11 1/2 + 1/4 .75 .101 1/2 + 0 + 1/8 .625

## 2.2 Representation of Numbers within the Computer

In any calculating device, some limit is imposed upon the range of numbers which can be directly represented. For example, on the lower scale of a slide rule, the numbers run from +1 to +10. Yet it is quite practicable to multiply .003 by -140 on the rule and obtain the result -.42, provided appropriate scale factors are applied to each operand and to the apparent result. Similarly, there is no real bar to using any device for calculating with numbers outside the range which can be directly represented.

In 803 this range is from -1 to just less than +1, achieved as follows:

1. In each word there are 39 digits.
2. The binary point is assumed to lie between the left-hand digit and that next to it.
3. Positive numbers, between 0 (which is regarded as positive) and the upper limit, 1 - 2-38, are represented directly by words beginning with 0, thus:
1. 0 0000 0000 0000 0000 0000 0000 0000 0000 0000 00
Zero
2. 0 1010 1000 0000 0000 0000 0000 0000 0000 0000 00
1/2 + 1/8 + 1/32 = 21/32 = .65625
3. 0 0000 0000 0000 0000 0000 0000 0000 0000 0000 01
2-38, the smallest possible positive number
4. 0 1111 1111 1111 1111 1111 1111 1111 1111 1111 11
2-1 + 2-2 + 2-3 + .... +2-38 = 1 - 2-38
the largest possible positive number.
4. Negative numbers, between -1 and -2-38, are represented by words beginning with 1, on the basis that the negative number (-x) is represented by (2 - x), thus:
1. 1 0101 1000 0000 0000 0000 0000 0000 0000 0000 00
this is 1 + 1/4 + 1/16 + 1/32 = 1 + 11/32
which is (2 - 21/32), so the word represents -21/32.

A quicker way of ascertaining the value of a negative number is to write -1 for the first digit, and then + 1/4 + 1/16 + 1/32 for the other "ones": adding gives -21/32 directly.

(This technique gives rise to an alternative explanation of the representation of negative numbers, namely that the first digit is -1 and the remainder are + fractions. This is misleading, for the computer treats all digits as positive.)

2. 1 0000 0000 0000 0000 0000 0000 0000 0000 0000 00
represents -1, the largest possible negative number.
3. 1 1111 1111 1111 1111 1111 1111 1111 1111 1111 11
represents -2-38, the smallest possible negative number.

This method of negative number representation is most satisfactory, for if the computer is made to add the two words representing 5/8 and -1/2 it actually adds 5/8 to 1 1/2 and tries, therefore, to produce the number 2 1/8, which would be:
10 0010 0000 0000 0000 0000 0000 0000 0000 0000 00
But there is no room in the word for the extra digit on the left: this is therefore lost, and the result appears as
0 0010 0000 0000 0000 0000 0000 0000 0000 0000 00
which is the proper representation of 1/8, the correct answer.

Similarly, all additions and subtractions are carried out correctly, provided that the true answer lies between -1 and 1-2-38. Multiplication and division are also correctly performed.

### 2.2.1 Sign Digit

The left-hand digit indicates the sign of a number, being 1 for negative numbers and 0 for zero and positive numbers. For this reason it is called the sign digit.

### 2.2.3 Complementing

Given the computer form of any number except -1,

e.g: 0 1110 1000 0000 0000 0000 0000 0000 0000 0000 00

or:   1 1111 1111 1111 1111 1111 1111 0101 0011 0110 11

to find the computer form of the equivalent negative number:

1. Working from right to left, write down 0 for all 0's, if any found before the first 1 is encountered.
2. Write down 1 for this 1.
3. Thereafter write 1 for 0 and 0 for 1.
Thus the negatives or "complements" of the above examples are
1 0001 1000 0000 0000 0000 0000 0000 0000 0000 00 and
0 0000 0000 0000 0000 0000 0000 1010 1100 1001 01

## 2.3 Scaling

(This section should be treated lightly at first reading, and re-read later when needed.)

Many problems require calculations to be done with numbers which exceed unity in magnitude. It is therefore generally neccesary to scale all numbers by a suitable factor, as in the example of the slide rule. We now examine this question and look at number representation from a fresh angle.

Consider the number 53 which, in binary has the six digits 110101. If we wish to construct a computer word to represent 53, we must add thirty-three zeros to make up a set of thirty-nine digits. These may all be placed to the left of the 110101, or some may be placed to the right and some to the left, thus:

1. 0 0000 0000 0000 0000 0000 0000 0000 0000 1101 01
2. 0 0000 0011 0101 0000 0000 0000 0000 0000 0000 00
3. 0 1101 0100 0000 0000 0000 0000 0000 0000 0000 00
Of these, (b) is an intermediate case, chosen at random, but (a) and (c) represent extremes. For if we try to place the 110101 any further to the right than (a), some digits will be lost, whilst if we place it any further left than (c), say:
1. 1 1010 1000 0000 0000 0000 0000 0000 0000 0000 00 or
2. 0 1010 0000 0000 0000 0000 0000 0000 0000 0000 00
either the result is "negative", as in (d), or digits are lost, as in (e), or both.

To enable us to describe the varying positions of the digits representing 53, we associate the values
20, 2-1, 2-2, 2-3 ..... 2-38
with the 39 digits of the word. We then inspect and determine in which position the units digit of the "53" lies, and we say that the word is, in case (a): 53 x 2-38, and in (b): 53 x 2-12, and so on.

But it must be understood that what these expressions mean is that in (a) the word represents 53, so placed that its unit digit appears at the right-hand end, while in (b) the word represents 53, so placed that its unit digit is 12 places to the right of the sign digit, with 26 places further to the right. For it is as important to know what the word represents, and how as what it is. To force this point home, although (b) is to us 53 x 2-12, i.e. 53 represented to scale 2-12, it could equally well be 106 x 2-13, or 1696 x 2-17 or 6.625 x 2-9.

The symbol "x" is used in this text as the "represented to scale" symbol in preference to the more frequently used "." to avoid confusion: for "53.2-12" could be read as "fifty three point two to the minus twelve".

### Arithmetic Operations on Scaled Numbers

If the computer is made to carry out an arithmetic operation with the word (b), it will carry it out as though it were in fact the number
(b) 53 x 2-12 (= 106 x 2-13 = etc.)
And if it is required to add it to
(f) 7 x 2-12 (= 14 x 2-13 = etc.)
(g) 60 x 2-12 (= 120 x 2-13 = etc.)

Similarly, provided the two numbers with which we are dealing are expressed to the smae scale, the computer will give the correct answer, in the same scale, in all addititve and subtractive operations.

But if (b) and (f) are multiplied, the answer will be
(h) 371 x 2-24 (= 1484 x 2-26 = etc.)

To bring this to the same scale as the original operands will require doubling, and the number of doublings will depend on the scale factor in use, for to bring 371 x 2-24 to scale 2-12 requires 12 doublings, but from 1484 x 2-26 to 1484 x 2-13 requires 13 doublings.

### Choice of scale

The choice of scale to use in any part of the calculation depends upon tqo premises, namely: the maximum magnitude of the numbers to be dealt with, and the accuracy to which the calculation must be performed. This is best shown by example:

(a) 53 x 2-38: 0 0000 0000 0000 0000 0000 0000 0000 0000 1101 01
(b) 53 x 2-18: 0 0000 0000 0000 1101 0100 0000 0000 0000 0000 00

Now (a) is such that a change of 1 in the last place corresponds to a change of 1 in the number represented. This scale is therefore suitable when dealing with integers, it is termed "integer scale", and the scale factor 2-38 is often omitted in writing when it is obvious that this scale is intended. The maximum positive capacity is 238-1 = 274,877,906,943

In (b) the right hand digit is 20 places to the right of the unit of the "53". A change of 1 here is therefore equivalent to a change of 2-20, or about one millionth, in the number represented. This scale is therefore suitable where such a degree of accuracy is required. The maximum positive number which can be represented is, in "non-computer" binary:

11 1111 1111 1111 1111 . 1111 1111 1111 1111 1111
which is evidently just less than
100 0000 0000 0000 0000 = 218 = 262,144
Attention is invited to the table of powers of 2 in Appendix 2.

### Fraction Scale

When all numbers to be used are less than unity in magnitude, they may be represented at full scale. Thus
0 1010 0000 0000 0000 0000 0000 0000 0000 0000 00
represents .625 "as a fraction". In this scale, the least change which can represented is 2-38 which is approximately .000 000 000 003 638.

If such a degree of accuracy is inadequate, a higher scale still may be used, but capacity is proportionately reduced.

### 2.3.3 Exercises

1. What is the smallest step, and what is the maximum capacity, in scale 2-6?
2. What (power of 2) scale should be used to obtainaccuracy to about one thousandth? What is the maximum capacity of this scale?

### Other Scales and Methods of Storing Numbers

We have, so far, only discussed scales in which tha factor is a power of two. That such scales may be more convenient than other is suggested by the multiplication problem of 2.3.1, where rescaling is done by doubling, a function provided by the computer. If the scale factor is not a power of 2, rescaling is somewhat more difficult. But other scale factors may be used, sometimes with advantage, where this consideration is of little or no importance.

In rare cases in which it is not possible to find a suitable scale factor for the solution of a particular problem, because the required accuracy and capacity cannot both be obtained simultaneously, recourse has to be had to other methods of number representation, termed "multiple-length" and "floating-point". The 803 library contains programmes which enable these methods to be used. See also Appendix 5.

When it is neccesary to store a lot of fairly short numbers in a limited number of locations, recourse may be had to a process termed packing, that is, making one word represent two or more numbers.

### Example 4

Taking the simplest case, where two positive integers, say 127 (1111111) and 341 (101010101) have to be stored together, we may proceed as follows:

Add 127 x 2-19 to 341 x 2-38 and store the result. Thus:

 0 0000 0000 0000 1111 1110 0000 0000 0000 0000 00 + 0 0000 0000 0000 0000 0000 0000 0000 0101 0101 01 = 0 0000 0000 0000 1111 1110 0000 0000 0101 0101 01
in which it can be seen that the two numbers have remained separate from each other.

When either number is required for arithmetic purposes, a copy of this word is taken from the store, and the unwanted number deleted by a function provided for the purpose.

## 2.4 The Overflow Indicator

Whenever the 803 carries out an arithmetic operation, it automatically tests the number to determine whether capacity is being exceeded. If this is so, a special device called the overflow indicator is set. The following operations, for example, would cause this; in all cases, the correct answer is outside the proper range, so the computer cannot represent it.

Operation Correct Result
1/2 + 1/2 1
-1 + -1/2 -1 1/2
-3/4 - 3/8 -1 1/8
Negate(-1) 1
-1 x -1 1
3/4 ÷ 3/8 2
Double 5/16 twice 1 1/4

Once it has been set, the overflow indicator remains set until one of two "test overflow indicator" instructions (43 and 47) is obeyed. These are conditional transfer instructions, by means of which the computer can be programmed to do one thing if overflow takes place and another if it does not. It is customary to insert one or other of these instructions at intervals in any programme in which there is a risk of capacity being exceeded. Since the overflow indicator, once set, remains set until tested, it is not neccesary to test after every operation.

A lamp on the keyboard is illuminated whenever the overflow indicator is set.

### 2.4.1 Deliberate Overflow

In certain cases it is possible to allow capacity to be exceeded, provided that compensating action is taken immediately.

For example, in the sequence:
Add 1/4 to 7/8, then subtract 3/8,
the addition of 1/4 + 7/8 produces 1 1/8 in the accumulator. This is the representation of -7/8, which is wrong, and the overflow indicator is therefore set. But the immediate subtraction of 3/8 from this gives the correct overall result 3/4.

Whenever the correct result of a series of additions and subtractions is within the range -1 to 1-2-38 inclusive, the 803 will give it correctly, even though the overflow indicator may be set during the series. Deliberate overflow may also be used when employing doubling, halving, multiplication and division functions but greater care is needed when doing so.

## 2.5 The Telecode

Perforated teleprinter tape, or punched paper tape as it is usually termed, is a medium upon which data area recorded by patterns of punched holes. One character consists of between 0 and 5 code holes in a line across the tape, arranged in 5 possible positions. Between the second and third code hole positions there is a small hole, termed the sprocket hole, which is required for mechanical purposes.

To the computer, a hole represents a 1, and "no hole" a 0; each character therefore represents a five-digit binary number between 00000 (zero) and 11111 (thirty one). It is important to appreciate that, although we may quite readily programme the computer to deal with letters, figures and symbols in whatever way we please, the computer recognises them only as groups of 5 binary digits or "bits".

To the teleprinter equipment used in preparing input tapes and interpreting output tapes, however, each of the 32 possible combinations of holes has one or two specific meanings as shown in Appendix 1.

To enable a teleprinter to distinguish between the two meanings of a character, two special characters are provided, "letter shift" and "figure shift" (ls and fs). One of these precedes each group of other characters on a tape, to indicate whether they are to be read as letters or as figures and symbols.

The character "line feed" (lf) is interpreted by a teleprinter as an instruction to print the next letters, figures or symbols on a new line, while "carriage return" (cr) causes printing to start or restart at the left hand margin. "Space" (sp) characters are inserted on a tape whenever required, to cause the teleprinter to space out the letters, figures and symbols. "Blank" (bl) has no meaning, and the teleprinter will ignore it; several inches are punched at each end of a tape to simplify handling.

The choice of characters used to represent figures is governed by the rules:

1. The right-hand four digits are the binary form of the figure represented.
2. The left-hand digit is such that the total number of 1's is odd. This digit is termed the parity digit.

These rules are made so that, respectively:

1. Conversion to and from pure binary is relatively simple: all that is needed is to remove or insert the parity digit.
2. The most common mechanical errors in punching, which are
1. Insertion of one extra hole,
2. Omission of one hole,
3. Omission of all holes,
may easily be detected in all numerical data.

## 2.6 Representation of Instructions

When a word represents a pair of instructions, each instruction is denoted by a group of 19 digits, 6 for the function and 13 for the number. The odd digit, which is the middle digit of the word, is termed the B digit: this has a special purpose which will be described later.

The layout is shown below. Each function is denoted by six binary digits, which correspond, in two sets of three, to its two-digit octal reference number. Thus function 43 (four-three, not forty-three) is, in binary, 100011. This provides a convenient means of grouping the functions in eight groups of eight; thus group 0 comprises functions 00 to 07, Group 1 comprises functions 10 to 17 and so on to group 7, which consists of functions 70 to 77.

The thirteen N digits in each instruction are sufficient to provide a range of N from zero to 1111111111111 = 8191 i.e. to enable the address of any location in a store of 8192 locations to be specified. This is the largest size of store which can be fitted in an 803.

Each 803 computer with a store of 4096 locations is adjusted in such a way that, if it is called upon to obey an instruction in which N is larger than the address of the last location in the store, it will ignore the left-hand N digit. Thus the instruction 04 4104 is treated as the instruction 04 8. Where the store has 2048 (1024) locations, the two (or three) left-hand N digits are ignored.

## 2.7 Store Parity Checking

Whenever one word, of 39 digits, is placed in the store, an artificial 40th digit is automatically appended and stored with it: this is termed the parity digit, and is a 1 or a 0 as may be needed to make the total number of 1's in the whole group of 40 digits odd. When a word is taken from the store, the number of 1's in its 40 digits is checked. If this is found to be odd, the parity digit is deleted, and the computer proceeds normally. If it is even, the checking circuit gives rise to a special signal. In the basic 803 the effect of this signal is to stop the computer and illuminate a lamp on the keyboard.

This facility cannot be controlled by programming methods, and the subject is not discussed further.

 Previous Chapter Contents Next Chapter