The LnXP1() function is used to calculate the natural logarithm of a number that is being incremented to 1. The syntax of this function is
Extended __fastcall LnXP1(Extended X);
When executing, this function takes one argument, X, adds 1 to X, and then calculates the natural logarithm, also called the Napierian logarithm, of the new number. The formula used is
|
Result = ln(X+1)
Here is an example:
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
Extended X, Result;
X = StrToFloat(Edit1->Text);
Result = LnXP1(X);
Edit2->Text = FloatToStr(Result);
}
//---------------------------------------------------------------------------
The Log10() function calculates the base 10 logarithm of a number. The syntax of this function is:
Extended __fastcall Log10(Extended X);
The number to be evaluated is passed as the argument X. The function returns the logarithm on base 10 using the formula:
y = log10x
which is equivalent to
x = 10y
Here is an example:
|
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
Extended X, Result;
X = StrToFloat(Edit1->Text);
Result = Log10(X);
Edit2->Text = FloatToStr(Result);
}
//---------------------------------------------------------------------------
The Log2() function is used to calculate the logarithm of a number on base 2. The syntax of the function is:
Extended __fastcall Log2(Extended X);
The variable whose logarithmic value will be calculated is passed as argument X to the function. The function uses the formula:
Y = log2x
This is the same as
|
x = 2y
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
Extended X, Result;
X = StrToFloat(Edit1->Text);
Result = Log2(X);
Edit2->Text = FloatToStr(Result);
}
//---------------------------------------------------------------------------
|
|