Currently for angles above 1.E18 the code returns 0. for Sin & 1. for Cos. The FPU provides accurate answers upto angles of over 9.22E18. I illustrate this improved accuracy for one angle in this range: 5.E18 (which can be represented exactly as a 64-bit REAL).

With the proposed change:

Sin (5.E18) = −0.825512

Cos (5.E18) = 0.564385

Tan (5.E18) = −1.462675

The precise answers are:

Sin (5.E18) = −0.829128

Cos (5.E18) = 0.559059

Sin (5000000000000000000.006437) = −0.825512

Cos (5000000000000000000.006437) = 0.564385

Tan (5000000000000000000.006437) = −1.462675

Note that an ULP (Unit in the Last Place) is 1024, so the approximate result is in fact the exact result for some x within 6 millionths of an ULP of the argument 5.E18.

This shows that the FPU does provide a good (useful) accuracy over this range, and accessing it has no cost (in fact it simplifies and speeds the code) so I hope you will support this proposal. I will post the changed Mod files shortly; no changes to Docu or Rsrc files are anticipated since the current unnecessary limitation is not documented.

To avoid merge conflicts I will wait until issue 151 is resolved; the proposed changes are illustrated below:

- Code: Select all
`PROCEDURE Sin* (x: REAL): REAL;`

BEGIN

(* 20, ABS(x) # INF *)

FLD(x); FSIN; WAIT;

IF 10 IN FSWs() THEN RETURN 0. END;

RETURN TOP()

END Sin;