222 114 223KB
English Pages [3] Year 1952
on m a g n e t i c t a p e s and c o n t r o l returns to the routine being tested until another cheek point is reaehe4,
i n c o r r e c t q u a n t i t y i s known t o a p p e a r t t o a c e l l whose c o n t e n t s h a v e c h a n g e d f o r an u n d e t e r m i n e d r e a s o n , o r t o an i n s t r u c t i o n containi n g variable addresses; but also has i n c i d e n t a l u s e s , such as l o o k i n g at successive terms o f a series without altering the coding. 2.
.
Effectively, this auxiliary r o u t i n e u s e s o n l y t h e f i r s t 8 memory locations, conventionally reserved, on SEAC, f o r t h e i n i t i a l read-in Instruotlone. Actually it temporarily u s e s o t h e r p a r t s o f t h e memory by first transferring their contents t o m ~ n e t l e t a p e s and later r e s t o r i n g them.
An i n t e r p r e t i v e r o u t i n e which d e t e r m i n e s the path which the control has taken through another routine. At e a c h comparison order, thls routine reade o u t t h e a d d r e s s o f t h a t o r d e r , and t h e a d d r e s s from w h i c h t h e n e x t This r o u t i n e o r d e r will be t a k e n . s e r v e s much t h e s a n e p u r p o s e a s t h e EDSAC r o u t i n e w h i c h r e a d s o u t t h e o p e r a t i o n symbol o f e a c h i n s t r u c t i o n executed.
What one t r i e s t o a c h i e v e i n d e s i g n ing such auxiliary routines is to program t h e m a c h i n e t o s e l e c t t h e p e r t i n e n t Information rather than to read out large q u a n t i t e s o f d a t a w h i c h must be s e a r c h e d t h r o u g h by a programmer. I wish to acknowledge the contrib u t i o n s o f C . J . S w i f t and J . H . W e g s t e l n o f t h e NBS C o m p u t a t i o n L a b o r a t o r y t o the ideas presented here.
A routine which determines the total effect, on t h e high s p e e d memory, of each of several chosen sections of the routine being tested. Check p o i n t s in t h i s latter r o u t i n e a r e p i c k e d by t h e programmer, and s p e o i fi~ to the computer. The e f f e c t o f the operation is that the computer e x e c u t e s one s e c t i o n o f t h e r o u t i n e b e i n g t e s t e d , then r e a d e out the a d d r e s s e e and c o n t e n t s o f memory locations which have been altered by t h a t s e c t i o n . Then i t e x e c u t e s a n o t h e r s e c t i o n and r e a d s o u t t h e c h a n g e s i t h a s made, and so on. The c o m p u t e r a c c o m p l i s h e s t h i s by f i r s t d u p l i c a t i n g t h e memory c o n t e n t s on a m a g n e t i c t a p e and r e p l a c i n g t h e instructions a t c h e c k p o i n t s by Instruotlons whloh will transfer c o n t r o l t o t h e auxiliary roatlne. Arrangement Is made, of course, f o r t h e e x e c u t i o n o f t h e replaced instructions a t the proper time. Then the first section of the main routine to entered, not in the interpretive manner, but dlreotly. When a c h e c k p o i n t i s r e a c h e d , t h e i n f o r m a t i o n i n t h e memory and on the m a g n e t i c t a p e are c o m p a r e d , and t h e a d d r e s s e e and new c o n t e n t s o f locations which have been changed are read out. Then t h e p r e s e n t c o n t e n t s o f t h e memory a r e d u p l i c a t e d
Note
on by
' C o m p u t e r A i d s to C o d e I . C . Diehm, N.B.S.
Checking'
P r o g r a m m e r s of the E c k e r t - M a u c h l y Division are u s i n g a r o u t i n e that has p r o v e d h e l p f u l in d e t e c t i n g one c l a s s of programming errors -- e r r o r s in t h e a d d r e s s p o r t i o n of i n s t r u c t i o n s . F u r t h e r m o r e , t h i s r o u t i n e h e l p s to p r e v e n t the i n s e r t i o n of n e w e r r o r s d u r i n g the p r o c e s s of c o r r e c t i n g o l d ones. The 'codecheck' routine examines a p r o g r a m and l o c a t e s e v e r y i n s t r u c t i o n r e f e r r i n g to e a c h l o c a t i o n , for e x a m p l e , 537. T h e r e f e r e n c e s are p r i n t e d t o g e t h e r w i t h t h e i r line n u m b e r s for e a s y identif i c a t i o n . T h u s , one list c o n t a i n s e v e r y line of c o d i n g w h i c h can p o s s i b l y a f f e c t location 537. C o d e c h e e k performs this operation for e v e r y ' l o c a t i o n from 000 through 999. In g e n e r a l , less time on the c o m p u t e r is r e q u i r e d t h a n for n t r i a l run of the p r o g r a m b e i n g t e s t e d .
B. Hasbrouck" Eckert-Mauchly Division of Remington Rand
INPUT SCALING A N D OUTPUT SCALING FOR A BINARY
CALCULATOR By
E. F. Codd and H. L. H e r r i a k International B u s i n e s s Machine Corp., New York
shifting operations which may be built into the calculator).
Input Scaling Suppose 1) the input for a p r o b l e m which is to be solved on a binary c a l c u l a t o r is given in d e c i mal form; 2) the p r o g r a m m e r d e s i r e s to s p e c i fy in his p r o g r a m the s c a l e f a c t o r s to be applied to i n t e r m e d i a t e r e s u l t s to keep these r e s u l t s within the capacity of the r e g i s t e r s of the c a l c u l a tor; 3) the s c a l e f a c t o r s to be applied a r e p o w e r s of two (this allows advantage to be taken of the
The following questions may now be asked. 1) Can p r e l i m i n a r y scaling of the decimal input (either by hand or on an a u x i l i a r y decimal c a l culator) be avoided? 2) If the binary c a l c u l a t o r can Be p r o g r a m m e d to c a r r y out s o m e e q u i v alent f o r m of scaling, how c l o s e l y does the c o n v e r t e d and s c a l e d input a p p r o x i m a t e to the 21
original input? 3) Is it possible to r e c o v e r the original input exactly from the scaled input in case, for example, it is required that the information stored be printed out in decimal form ?
then it can be shown that, if 2q~ - 10P, the integral part of x equals the integral part of y. As a result the storage space required for y can be calculated by considering separately the number of binary positions required for the integral part of x and the number of binary positions required for the fractional part of y.
A method will now be described for using the binary calculator itself to scale the input and in such a way as to obtain the best possible accuracy together with exact reconversion. This method is sufficiently general to form the basis of a standard input program. Once such a program has been developed, the programmer.is relieved of m u c h of the labor of p r e p a r i n g decimal input in a form suitable for a b i n a r y calculator.
The case p = q = 0 is trivial. Suppose, then, that 2q ~ 10P and let the fractional part of x be denoted by xf. Since xf has a p-decimalplace representation m a x (xf) = I - 10 -p ¢ i - 2 -q
If the max~x~) is rounded to q binary places, at most 2-@I#I) is added. Hence, the result w of converting and scaling m a x (xf) is given by
Consider a calculator in which numbers are represented to a precision of n binary digits. In the I B M Type 701 calculator there are two word sizes: n = 17 and n = 35, (excluding sign bits, which are not relevant to this discussion). Let q binary digits represent the fractional part of any n-binarydigit number. Further, suppose the decimal input consists of m-declmal-digit n u m bers, in each of which p digits represent the fractional part. For convenience, these numbers will be assumed to be non-negative. Assume, also, for the present that both p (the n u m b e r Of decimal places) and q (the number of binary places) are specified for each n u m b e r x to be loaded. Since x has p decimal places, 10Px is an integer. The exact binary representations of the integers lopx, p, q can be obtained in the binary calculator by straight forward decimal-to-binary conversion. Using p as argument, l0 p in binary form can be selected from a table of powers of ten stored in the calculator. The dividend 10Px and the divisor lop can now be positioned so that a rounded * quotient x is developed which has q binary places. For a calculator which gives an overflow on division if the dividend is numerically larger than the divisor, •this positioning consists of shifting the divisor to the left s binary places and the dividend to the left q-s binary places (q ~ s) or to the right s-q places (s ~- q) where s is defined by the inequallty 2- I - ~
2 -s
by hypothesis.
w
m a x (x~) +'2-~(q+},) 1 - 2-q + 2 -(q+±) ¢
1
This can be interpreted as meaning that no carry occurs from the fractional part of x to the integral part of x when x is rounded to q binary places. Consequently, the integral part of x equals the integral part of y. It may also be shown that: if I) any p-decimal-place number x is converted and scaled to give a q-bina~-place number y such that Ix-yl -~ 2-(q+±), and 2) y is scaled and converted back to a p-~ecimal-place number z such that ly-zl _~ 2- 10-P;then z=x for all x if, and only if, 2q~- 10p. The case p = q = 0 is again t r i v i a l . Consider, therefore, p ~ 0. •
z-xl-Iz-yl + ly-xl
~ 2 - i 10-P + 2-(q+l) < 10-P if, and only if, 2q> 10p.
But both z and x are p-decimal-place numbers. Hence, Iz-xl < i0 -p implies z = x. The results obtained above may be summarized as follows: i) In order to obtain exact reconversion of any p-decimal-place number x the binary representation of x should be rounded to q-binary-places, where 2q ~-10P, ~, giving a number y such that Ix-~2-(q+i);
l0 p ~ I .
Some d e s i r a b l e f e a t u r e s of this method of converting and scaling a r e : i) A converted and scaled number differs from the given number by at most 2-(q+l); 2) Only one type of conversion (namely, that appropriate for integers) is required; 3) The conversion of x need not be postponed until p has been converted.
2) Under these conditions the integral part of x equals the integral part of y. Therefore, the storage space required for y can be calculated by considering separately the number of binary positions required for the integral part of x and the number of binary positions required for the fractional part of y.
It should be noted that f r a c t i o n - t y p e c o n v e r s i o n from d e c i m a l - t o - b i n a r y in a b i n a r y calculator, i n g e n e r a l , does not give the best a c c u r a c y possible.
Suppose that 2t-l_~Ixl-2t, where t is an integer. Then the minimum number of binary positions required for the integral part of x is t. Now, if 10Px is an integer and the exceptional case in which x has both a finite decimal representation and a finite binary representation is excluded, then the m i n i m u m number of binary positions required for the
If a p - d e c i m a l - p l a c e n u m b e r x i s converted and scaled as d e s c r i b e d above to give a q b i n a r y - p l a c e n u m b e r y such that Ix-y] a 2--(q+1), * rounded by half-adjusting. 22
fractional part of y is s, where s is the integer satisfying the inequality 2 -I~- 2 -s 10P-I.
The i n t e g e r - t y p e c o n v e r s i o n from decimal to binary is checked by i n t e g e r - t y p e c o n v e r s i o n from binary to decimal and the scaling is checked by descaling. Both checks a r e exact.
The minimum number of binary positions required for y is therefore s + t. (Note: the sign and sign position are excluded from this discussion.) If a register is available with a digital capacity greater than s + t binary positions, the extra positions m a y be allotted to the integral part or fractional part or both.
Output Scaling If results developed by a binary calculator are to be printed out in decimal form it seems desirable that any scaling involved be done by the binary calculator after the printing. A qbinary-place number y m a y be scaled and converted to a p-decimal-place n u m b e r z with the best possible accuracy (i.e., Iz-~ _~2 -I i0 -p) by multiplying y by IO p, shifting the product to give 2 -~ lOPy, rounding this product and then converting it to decimal form by integertype conversion.
In order to load a set of numbers x~ each of which has p decimal places, any q m a y S e chosen satisfying the inequality s_~q_~n-t where i) 2-i~-2 -s loP