Scor­pio News


January–March 1987, Volume 1, Issue 1

Page 48 of 63

‘The accuracy of the results obtained with a computer depends critically upon the

level of precision to which the language implementation does its calcdlattons –

(or any do which the accuracy of the result bad co be

i) would need to be structured

pos eof algnitcant flgures were employed snd 0

plied. can be achieved by the use of double precision

arithmetic but there ie a time and memory penalty for its use. On the other

hand. Le program to calculate the acess of triangles or to work out

nts needs only single precision arithmetic – the default on most

“and rounding off may be permissible. The use of built-in ‘trace’ oF

debugging facilities can allow intermediate results to be examined if final

Fesults ate not at would be expected. One should not accept the computer’s Feaults uneritically”

Resource efficiency

‘Two major constraints on most microcomputer users are the anount of directly Sie memory and the execution tise of progcam, c large adventure

ost of what aly ape

it down a bit unl

‘cant help economize on menor

re if the legibility of the program i

ys in which large arcaye of dat

Tong time vo do tt

‘optimized By cutting out unnecessary steps and optimizing whece possible. A few

ckanples may help iilusteate this point.

It 2 quicker to use addition and subtraction rather than multiplication #0 Aovey fa faever than Xe20Y. Multiplication is faster chan division s

rere vexy2 exer is faster than vo/z vover woalz went

caponentiation is very slow, particularly when the ‘power’ used is a non-Integer. Te de « lot quicker to multiply:

ToXeKeK {9 quicker than TeX"3 (or ToX*#3) and a lot quicker than Tox Implies that a non-integer pover is used (this does not apply to BASIC 1am avare).

‘Always use the supplied functions such

SQR or SQRT; the results are usually ore accurate and more quickly obtained than If you devise your own vers

Use a fractional exponent! If you need to write your own functions (such which {en’e found in most PASCALe oF PORTRANS) do check your vereion welng Suitable values and paper’ and penctl

Inefficient programmers often repeat calculations within the same statement or


AcBec-K+4*(BtC)/Y could run faster a two statements:

panic ASPoasAAPY

Further savings in time can be gained by examining the way in which arrays are

fcceased. ff an ar a several times in a Calculations, the valu ay element, can be aesigned to’s variable and this variable deed in the calcuZatione which follow:

2X13) Aepexct,s)

Asbo, ds better than Tacexcr. 3)


This is an OCR’d version of the scanned page and likely contains recognition errors.

Page 48 of 63