tan(pi/2) overflow

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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:
_________________________

#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:

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

is giving this output:

./test-float.out 
No overflow
1.63312E+16

Even compiling this way:

gcc -ftrapv -fwrapv -fexceptions -Wall -lm -g -o test-float.out\
test-float.c

the output is the same.

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

Thanks.



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux