Home

Arithmetic: The Exponential of a Number

double exp(double x);

The exp() function calculates the exponential value of a number. The argument, a double-precision value, represents the number to be evaluated.

If the value of x is less than -708.395996093 (approximately), the result is reset to 0 and qualifies as underflow. If the value of the argument x is greater than 709.78222656 (approximately), the result is INF and qualified as overflow:

//---------------------------------------------------------------------------
#include <iostream.h>

#pragma hdrstop
//---------------------------------------------------------------------------
#pragma argsusedint main(int argc, char* argv[])
{
    cout << "\nThe exponential of "
	 << 709.78222656 << " is " << exp(709.78222656);
	
    cout << "\n\nPress any key to continue...";
    getchar();
    return 0;
}
//---------------------------------------------------------------------------

Therefore, the value of the argument should be between these two extremes. For a larger number, use the expl() function:

long double expl(long double x);

As opposed to an 8-byte value, this version of the function takes a 10-byte variable, calculates its exponent, and returns a long double.

 
Home Copyright 2004-2007 FunctionX, Inc.