Fix for a crash which happened when a document couldn't be opened.
[AROS-Contrib.git] / fish / icalc / math.c
blob409cbb65aee30aaf82b41a21c4380a2474059c33
1 /*
2 * standard (real) math routines with domain/range checking, for
3 * complex-number expression parser.
4 * MWS, March 17, 1991.
5 */
6 #include <math.h>
7 #include <errno.h>
8 #include "complex.h"
9 //#include <libraries/mathieeedp.h>
11 extern struct Library MathIeeeDoubTransBase;
13 double Sqrt(x)
14 double x;
16 return errcheck(sqrt(x), "sqrt");
19 double Log(x)
20 double x;
22 return errcheck(log(x), "log");
25 double Asin(x)
26 double x;
28 return errcheck(asin(x), "asin");
31 double Acos(x)
32 double x;
34 return errcheck(acos(x), "acos");
37 double errcheck(d, s) /* check result of library call */
38 double d; /* doesn't seem to work under Lattice... */
39 char *s;
41 if (errno == EDOM) {
42 errno = 0;
43 execerror(s, "argument out of domain");
44 } else if (errno == ERANGE) {
45 errno = 0;
46 execerror(s, "result out of range");
48 return d;