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>exp() calculate exponential</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
exp()                    Calculate Exponential

 #include   <math.h>

 double     exp(x);
 double     x;                           Floating-point value

    exp() returns the exponential function of 'x'.

    Returns:    Exponential function of 'x'.  On overflow, matherr() is
                called with an OVERFLOW error, set to ERANGE (defined in
                <math.h>), and the value HUGE (defined in <math.h>) is
                returned.  On underflow 0.0 is returned. (matherr() is
                not called on an underflow, and 'errno' is not set.)

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

                OVERFLOW first occurs with 'x' greater than 7.0E2.


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

    The following statements continue printing the exponential function
    of the values in an array until an OVERFLOW error occurs.

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

                              /* the value 1000.0 will cause an error */
         double values[6] = {0.0, 1.0, -1.0, -500, 1000.0, -0.2};

         main()
         {
             double exponential;
             int i;

             errno = 0;
             for (i = 0;  !errno && i < 6;  i++) {
                 exponential = exp(values[i]);
                 if (errno == ERANGE) /*an error is also printed to stderr */
                     printf("OVERFLOW error in exp()\n");
                 printf("exponential function of %f = %f\n",
                        values[i], exponential);
             }
         }

See Also: log() log10() matherr() pow()

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