I set out to investigate the accuracy of 4 different versions of BBC Basic, from 1982 to 1988, and discovered - horror - some major inaccuracies in the 1988 version, 4.32. I found these problems in emulation and then checked on a real machine.

I hope no-one was planning on designing any rockets or nuclear reactors with this version of Basic!

Here are some failing cases:

Code: Select all

```
Function Basic 4r32 Correct value
P.LN(1.03125) 3.07692308E-2 3.07716587E-2
P.ASN(0.03125) 3.126527E-2 3.12550885E-2
P.ACS(0.03125) 1.53953106 1.53954124
P.ATN(0.9375) 0.753140099 0.753151281
```

In case it's interesting, what I did was cook up some identities, so for example

should mathematically be zero. So if we compute lots and add up the errors, we see how far out the 5-byte floats are. And comparing the 4 versions, we can see a general improvement in accuracy followed by a catastrophe:

Code: Select all

```
E=0:FORI=0.03125TO1.5STEP.0625:E=E+ABS(ACS(COS(I))-I)/I:N.:P.E
1.43308147E-7
1.24047257E-7
1.17482481E-7
3.25589539E-4
```

We ought to get a good 8 digits of accuracy from each calculation. But in 4r32 it can be much worse - so I looked for particular values which gave large errors:

Code: Select all

```
>P.LN(EXP(2.125))
2.12499212
>P.ASN(SIN(0.03125))
3.12601765E-2
>P.ACS(COS(0.03125))
3.12601733E-2
>P.TAN(ATN(0.9375))
0.93747899
```

For most calculations I tried, Basic 4.8 and 4r32 give exactly the same answers. So I suspect what happened is a small tweak intended to improve performance which actually introduced an accuracy bug. I might dig into the code to see what's changed.