Hello.

Though the GNU libc manual says:

"Mathematically, the tangent function has singularities at odd multiples of pi/2. If the

argument x is too close to one of these singularities, tan will signal

overflow."

the next code:

Code:

#include <stdio.h>
#include <math.h>
#include <fenv.h>
int
main (void)
{
double val1;
int raised;
#if defined(FE_OVERFLOW)
feclearexcept (FE_ALL_EXCEPT);
val1 = tan (M_PI/2);
raised = fetestexcept (FE_OVERFLOW);
if (raised)
printf ("Overflow\n");
else
printf ("No overflow\n");
printf ("%G\n",val1);
#else
printf ("FE_OVERFLOW not defined\n");
printf ("%G\n",tan(M_PI/2));
#endif
return 0;
}

compiled this way:

Code:

gcc -Wall -lm -g -o test-float.out test-float.c

is giving this output:

> ./test-float.out

No overflow

1.63312E+16

So, anyone knows how can I get tan(pi/2) to raise the overflow exception.

Thanks.

## Bookmarks