Home

Math Functions: The Exponential

     

Description

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

double exp(double x);

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 <vcl.h>
#include <math.h>
#pragma hdrstop

#include "Exercise.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
	: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::btnExponentialClick(TObject *Sender)
{
	double Number = edtNumber->Text.ToDouble();

	edtExponential->Text = exp(Number);
}
//---------------------------------------------------------------------------

Here is an example of running this code:

Exponent

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 value.

 
 
     
 

Home Copyright © 2010-2016, FunctionX