Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ exp(3) — AIX/RT 2.2.1

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

fpfp

Exception Handling

hypot

matherr

sinh, cosh, tanh

exp, log, log10, pow, sqrt

Purpose

     Computes exponential,  logarithm, power, and  square root
     functions.

Library

     Math Library (libm.a)

Syntax

     #include <math.h>

     double exp (x)                            double pow (x, y)
     double x;                                 double x, y;

     double log (x)                            double sqrt (x)
     double x;                                 double x;

     double log10 (x)
     double x;
     Description

     The exp subroutine to returns e(x).

     The log subroutine returns the natural logarithm of x,
     ln x
     .  The value of x must be positive.

     The log10 subroutine returns the logarithm base 10 of x,
     log sub 10 % x
     .  The value of x must be positive.

     The pow subroutine  returns x(y).  The values of  x and y
     may not both be 0.  If x is negative or 0, then y must be
     an integer.

     The sqrt  subroutine returns the  square root of  x.  The
     value of x cannot be negative.

     Diagnostics

     The  exp, log,  log10, and  sqrt subroutines  can perform
     either of the following types of error handling.  The pow
     subroutine always  handles errors according to  the first
     method.  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-292.  The default error-handling
         procedures for these subroutines are as follows:

         exp     If the  correct value overflows,  exp returns
                 HUGE and sets errno to ERANGE.

         log     If x is  negative or 0, then  log returns the
                 value -HUGE,  sets errno to EDOM,  and writes
                 an  error  message   to  the  standard  error
                 output.

         log10   If x is negative or 0, then log10 returns the
                 value -HUGE,  sets errno to EDOM,  and writes
                 an  error  message   to  the  standard  error
                 output.

         pow     If  x  is negative  or  0  and  y is  not  an
                 integer, or if  x and y are both  0, then pow
                 returns the value 0,  sets errno to EDOM, and
                 writes an error message to the standard error
                 output.  If the  correct value overflows, pow
                 returns HUGE and sets errno to ERANGE.

         sqrt    If x is negative, then sqrt returns the value
                 0, sets  errno to  EDOM, and writes  an error
                 message to the standard error output.

     2.  For exp, log, log10, and sqrt, 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 pre-
         processor 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 exp, log,
         log10,  and sqrt  appear to  the compiler  as _C_exp,
         _C_log, _C_log10,  and _C_sqrt,  respectively.  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," "hypot,"
     "matherr," and "sinh, cosh, tanh."

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