|
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);
}
//---------------------------------------------------------------------------