summaryrefslogtreecommitdiff
path: root/src/math/tan.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/math/tan.c')
-rw-r--r--src/math/tan.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/math/tan.c b/src/math/tan.c
index 2e60bd2f..061e6cdd 100644
--- a/src/math/tan.c
+++ b/src/math/tan.c
@@ -2,10 +2,17 @@
#include <math.h>
#include "_tgmath.h"
#include "errno.h"
+#include "fenv.h"
/** tangent **/
TYPE TGFN(tan)(TYPE x)
{
+ switch (fpclassify(x)) {
+ case FP_ZERO: return x;
+ case FP_INFINITE: feraiseexcept(FE_INVALID); return NAN;
+ default: break;
+ }
+
if (0) {
errno = ERANGE; /* The result cannot be represented */
/* RETURN_FAILURE(CONSTANT(HUGE_VAL), A range error occurred); */