summaryrefslogtreecommitdiff
path: root/src/math/acos.c
diff options
context:
space:
mode:
authorJakob Kaivo <jkk@ung.org>2019-03-03 21:25:50 -0500
committerJakob Kaivo <jkk@ung.org>2019-03-03 21:25:50 -0500
commit06696f40afe58a231e2531c8bf6d9f0dadb92e51 (patch)
treeb146422c6326ffe3debf3163f0941d8dda0be105 /src/math/acos.c
parentf20eeea657d62f2ef905627ca3a9094d33af7d40 (diff)
outline details from C18 annex F
Diffstat (limited to 'src/math/acos.c')
-rw-r--r--src/math/acos.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/math/acos.c b/src/math/acos.c
index 2f740d03..9a356100 100644
--- a/src/math/acos.c
+++ b/src/math/acos.c
@@ -1,12 +1,15 @@
# define TGSOURCE "acos.c"
#include <math.h>
+#include "fenv.h"
#include "errno.h"
#include "_tgmath.h"
/** arc cosine **/
TYPE TGFN(acos)(TYPE x)
{
- if (x < -1 || x > 1) {
+ if (TGFN(fabs)(x) > 1) {
+ feraiseexcept(FE_INVALID);
+ return NAN;
errno = EDOM; /* ARGUMENT(x) not in the range [-1, +1] */
return TGHUGE;
}
@@ -17,6 +20,10 @@ TYPE TGFN(acos)(TYPE x)
return TGHUGE;
}
+ if (x == 1.0) {
+ return 0.0;
+ }
+
/* RETURN_SUCCESS(a value in range `[0, PI()]'); */
return (TYPE)0.0;
}