Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ sin(3) — AIX/RT 2.2.1

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

fpfp

Exception Handling

matherr

sin, cos, tan, asin, acos, atan, atan2

Purpose

     Computes trigonometric functions.

Library

     Math Library (libm.a)

Syntax

     #include <math.h>

     double sin (x)                            double asin (x)
     double x;                                 double x;

     double cos (x)                            double acos (x)
     double x;                                 double x;

     double tan (x)                            double atan (x)
     double x;                                 double x;

                                               double atan2 (y, x)
                                               double x, y;
     Description

     The sin, cos, and tan subroutines return the sine, cosine
     and tangent, respectively, of their parameters, which are
     in radians.

     The  asin subroutine  returns the  arcsine of  x, in  the
     range -&pi./2 to &pi./2.

     The acos  subroutine returns the  arccosine of x,  in the
     range 0 to &pi..

     The atan subroutine  returns the arctangent of  x, in the
     range -&pi./2 to &pi./2.

     The atan2  subroutine returns  the arctangent of  y/x, in
     the range -&pi. to &pi.,  using the signs of both parame-
     ters to determine the quadrant of the return value.

     Diagnostics

     These  subroutines can  perform either  of the  following
     types of  error handling.   Both types of  error handling
     allow you to  define special actions to be  taken when an
     error occurs.

     1.  By default,  matherr error handling is  performed, as
         described on page  3-287.  The default error-handling
         procedures for these subroutines are as follows:

         sin, cos, tan
            The  sin, cos  and tan  subroutines lose  accuracy
            when  passed a  large value  for the  x parameter.
            For sufficiently large parameters, these functions
            return 0 when there  would otherwise be a complete
            loss  of significance.   In this  case, a  message
            that  indicates  a  TLOSS   error  is  written  to
            standard error.  For less  extreme values, a PLOSS
            error is generated but  no message is written.  In
            both cases, errno is set to ERANGE.

            The tan  subroutine returns HUGE if  its parameter
            is near an odd multiple of &pi./2 when the correct
            value would overflow, and sets errno to ERANGE.

         asin, acos
            The  asin and  acos subroutines  return 0  and set
            errno to EDOM if  their parameters are larger than
            1.0.  In addition, an error message that indicates
            a domain  error is  written to the  standard error
            output.

     2.  Exception handling can also be performed according to
         ANSI/IEEE standard 754-1985 for binary floating-point
         arithmetic, as discussed  under "Exception Handling."
         To  select ANSI/IEEE  exception handling,  define the
         _C_func preprocessor  variable.  You  can do  this by
         inserting  the statement  #define _C_func before  the
         #include <math.h>,  or  by specifying  the  -D_C_func
         flag to the cc command when compiling the program.

         If a  hardware floating-point processor  is installed
         in your  system, then  using this option  can provide
         greater  performance in  addition  to IEEE  exception
         handling.  Defining _C_func  causes the math.h header
         file to define  macros that make the  names sin, cos,
         tan, . . . appear  to the compiler as _C_sin, _C_cos,
         _C_tan, . .  . .  These special names  instruct the C
         compiler to generate code that avoids the overhead of
         the math  library subroutines and  issues compatible-
         mode floating-point  calls directly.  See  "fpfp" for
         information about compatible mode.

     Related Information

     In  this   book:   "fpfp,"   "Exception   Handling,"  and
     "matherr."

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026