Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Turbo C - <b>tan() calculate tangent</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
tan()                    Calculate Tangent

 #include   <math.h>

 double     tan(x);                      Tangent
 double     x;                           Radians

    tan() returns the tangent of 'x' radians.

    Returns:    Tangent of 'x'.  If 'x' is large, a partial loss of
                significance in the result may occur, in which case
                matherr() is called with a PLOSS error, 'errno' (defined
                in <stdlib.h>) is set to ERANGE (defined in <math.h>),
                and the partially insignificant result is returned.  If
                'x' is so large that a total loss of significance occurs,
                then matherr() is called with a TLOSS error, a TLOSS
                error message is printed to 'stderr', 'errno' is set to
                ERANGE, and 0.0 is returned.

      Notes:    Error handling can be modified by using the matherr()
                function.

                PLOSS first occurs with 'x' greater than 1.0E8.

                TLOSS first occurs with 'x' greater than 2.0E9.

  -------------------------------- Example ---------------------------------

    The following statements print the tangent of 2 pi radians and 4.9e7
    pi radians and check for any loss of significance.

         #include <math.h>       /* for tan() and ERANGE */
         #include <stdio.h>      /* for printf() */
         #include <stdlib.h>     /* for errno */

         main()
         {
             double tangent, pi = 3.1415926535;

             tangent = tan(2.0 * pi);
             printf("tangent of 2 * pi = %e\n", tangent);
             errno = 0;
             tangent = tan(4.9e7 * pi);
             /* if a TLOSS error occurs, a message is printed to stderr */
             if (errno == ERANGE)
                 printf("ERANGE error in tan()\n");
             printf("tangent of 4.9e7 * pi = %e\n", tangent);
         }

See Also: tanh() cos() matherr() sin()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson