Skip to content

Comparison Tolerance

Vector 3:2, page 131

language design mathematics and statistics

Transcribed from the printed issue; not yet reviewed. Read it in the PDF of the issue, page 131

One of the important qualities in a high-level language is that it should be divorced from the technicalities of computer jargon – the bits, bytes and binary syndrome that are such a joy to the computer professional and so frustrating to others. Everyone cannot be expected to thrill to the knowledge that asymptotic lines go on for ever getting closer and closer but never actually meeting, or that points can float.

As a devotee of APL, I believe that it is the best of the high-level languages, partly because it is not only a language in its own right but also a logical mathematical notation. It is very practical for people who are not noticeably philosophical, for people like me who used to thumb out the notes from my wages packet into little piles and put one pile into the tea-caddy for housekeeping, one under the mattress as savings for old age, and the remainder into my pocket for a night out at the pub, carefully moving the change from one receptacle to another. Now, with APL and my home-computer, I can calculate immediately that so-much for housekeeping and so-much for savings leaves me enough for 20 pints plus a flutter on the 2.30 at Doncaster. This simplicity is why APL appeals to me and why I have persuaded a number of clients, who are practical-minded business people, that APL is a “good thing” and a ray of hope in the tortuous and complex world of computing.

But due to an event which occurred recently with APL I am now in a state of complete shock.

I was asked to demonstrate APL to a prospective client and decided to illustrate it with a simple Ledger routine, a procedure I have adopted successfully many times before. The routine took each customer in turn, calculated a balance by subtracting payments from the amount due, and wrote a new record when the balance did not equal zero. The relevant statements looked something like this (written in Sinclair Keyword for the benefit of non-APL readers):–

.....
BALANCE is AMOUNTDUE -+on PAYMENTS  (the sum of payments)
GOTO NEXT if BALANCE eq(uals) 0
WRITE (Balance Record)
.....

Although I had already partially tested the function, the first hint of trouble came when we entered about 40 records from the client’s existing ledger and found that we had generated, from about 39 genuine zero balances, at least 15 new records which stated:–

Customer: BALANCE BT FWD  £00.00

“Ha!” said the client’s inevitable Mr. Knowall who was very anti-computers. “Hope we don’t send them all threatening letters for that.”

“No problem”, I assured him. “Just a logic error. We can take a look and see what the computer thought the BALANCE was.” I thought that maybe we had rounded up a half-penny out or some such.

But not a bit of it – we were out even less than that. Imagine my consternation when I displayed BALANCE and saw the value as:

¯7.105427358E¯15

The statement BALANCE = 0 produced the truth-vector response of 0, or untrue!

“What does that mean?” asked Mr. Knowall. “Have we won the pools?”

I will not flog the point, but I had thought that the purpose of Comparison Tolerance was to iron out silly, unrealistic situations like this. I know that I can avoid it happening by using integer pence instead of pounds to two decimal places, by formatting, by rounding, or in several other different ways. I know that zero is a special case, that the smaller the number the lesser the relevance of Comparison Tolerance. I know all that. But is it desirable that a user should have to cope with these hardware qualifications?

If we do a simple calculation like:

X←46.23 - (40.20 + 6.03)

and then display X and find:

¯7.105427358E¯15

What user-friendly, simple, mathematical notation is that, I ask you? Words fail me. Do I have to explain to my trusting and valued client that there are times, according to our so-called advanced computers, when nought does not equal zero?

Next day

I am in anguish. Oh! my beloved APL, what hast thou done to me? I have a vision of the instructor on the first BBC lesson in APL saying,

“Now the first thing you have to get into your heads is that, in this advanced logical language, zero is simply represented as:

¯7.105427358E¯15

got it?”

By the waters of Severn & Trent I lay down and wept!

Some days later

Now I should be feeling better. I have managed to speak about the problem to my bewidered wife, my astonished G.P., my wily psycho-analyst and, today, to a competent APL therapist. But the latter assures me that there is nothing to get upset about, that the machine is correct, and that the response is in accordance with the new ISO standard; there is, in fact, no problem.

I am distraught. Little symbols are darting out of nested arrays and feeding on tildes. My world has collapsed. The Romans didn’t know about zero, but the Arabs, thank goodness, invented it. Now it seems that computers and APL have destroyed it. Is this a nightmare? Am I going asymptotic? Cannot true zero exist in floating-point?

Matron’s bulletin, Dick Gray Associates’ Nursing Home

Patient is in intensive care. If the BSI APL standards committee feels it can do anything to help, please contact me urgently. Otherwise it may be:

GOTO END

(Editor: I feel compelled to offer a sympathetic voice, if only one that cannot offer a therapeutic solution. My own particular frustration is to find that the answer to the mathematically equivalent test:

1 = 1 + BALANCE

is (correctly) 1 or true. No doubt the definition is part of a devious plan by hardware suppliers to ensure that we need additional CPU resource to carry out the extra addition every time we want to compare with zero.)