X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=lib%2Ftanl.c;h=64a84b86f8ed7edd49065bec3e9275a757b40308;hb=0a9d9877fef46e7bc0a3eff16081d37016569981;hp=e4b974e3d2523fcdfc2b7b0074e4efefd084a5a7;hpb=5657b2536d242966c41c268b9ab4fe8df727bb13;p=gnulib.git diff --git a/lib/tanl.c b/lib/tanl.c index e4b974e3d..64a84b86f 100644 --- a/lib/tanl.c +++ b/lib/tanl.c @@ -14,6 +14,11 @@ * ==================================================== */ +#include + +/* Specification. */ +#include + /* tanl(x) * Return tangent function of x. * @@ -44,16 +49,13 @@ * TRIG(x) returns trig(x) nearly rounded */ -#include - -#include "mathl.h" - #include "trigl.h" #ifdef HAVE_SINL #ifdef HAVE_COSL #include "trigl.c" #endif #endif +#include "isnanl.h" /* * ==================================================== @@ -125,13 +127,13 @@ kernel_tanl (long double x, long double y, int iy) long double z, r, v, w, s, u, u1; int flag, sign; - sign = 1; - if (x < 0) - { - x = -x; - y = -y; - sign = -1; - } + sign = 1; + if (x < 0) + { + x = -x; + y = -y; + sign = -1; + } if (x < 0.000000000000000006938893903907228377647697925567626953125L) /* x < 2**-57 */ { @@ -190,13 +192,17 @@ tanl (long double x) long double y[2], z = 0.0L; int n; + /* tanl(NaN) is NaN */ + if (isnanl (x)) + return x; + /* |x| ~< pi/4 */ if (x >= -0.7853981633974483096156608458198757210492 && x <= 0.7853981633974483096156608458198757210492) return kernel_tanl (x, z, 1); - /* tanl(Inf or NaN) is NaN, tanl(0) is 0 */ - else if (x + x == x || x != x) + /* tanl(Inf) is NaN, tanl(0) is 0 */ + else if (x + x == x) return x - x; /* NaN */ /* argument reduction needed */ @@ -210,7 +216,7 @@ tanl (long double x) #if 0 int -main () +main (void) { printf ("%.16Lg\n", tanl(0.7853981633974483096156608458198757210492)); printf ("%.16Lg\n", tanl(-0.7853981633974483096156608458198757210492));