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

 #include   <math.h>

 double     acos(x);                     arccosine (in radians)
 double     x;

    acos() returns the arccosine of 'x' in radians.  The return value
    will be in the range 0 to pi.  'x' must be in the range -1.0 to 1.0.

    Returns:    The arccosine of 'x'.  If 'x' < -1.0 or 'x' > 1.0, then
                matherr() is called with a DOMAIN error; 'errno' (defined
                in <stdlib.h>) is set to EDOM (defined in <math.h>); a
                domain error message is printed to 'stderr'; and 0.0 is
                returned.

      Notes:    Error handling can be modified with the matherr()
                routine.

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

    The following statements continue printing the arccosines of the
    values in an array until a DOMAIN error occurs.

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

                                /* the value 3.141 will cause an error */
           double cosines[6] = {0.707, 0.0, 1.0, -1.0, 3.141, -0.2};

           main()
           {
               double arc_cosine;
               int i;

               errno = 0;
               for (i = 0;  !errno && i < 6;  i++) {
                   arc_cosine = acos(cosines[i]);
                   if (errno == EDOM) /* an error is also printed to stderr*/
                       printf("DOMAIN error in acos()\n");
                   printf("arccosine of %f = %f radians\n",
                          cosines[i], arc_cosine);
               }
           }


See Also: asin() atan() atan2() cos() matherr() sin() tan()

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