RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
System.ArcTan Function

Calculates the arctangent of a given number.

Pascal
function ArcTan(const X: Extended): Extended;
C++
Extended ArcTan(const Extended X);

In Delphi code, ArcTan returns the arctangent of X. 

X is a real-type expression that gives an angle in radians.  

C++ Examples: 

 

/*
This example shows how to use the ArcTan and FloatToStr
functions to approximate Pi.
*/
void __fastcall TForm1::Button1Click(TObject *Sender)
{
  Extended ex = 16 * ArcTan(1.0/5.0) - 4.0 * ArcTan(1.0/239.0); // Machin's formula
  String mystring = FloatToStr(ex);
  Edit2->Text = mystring;
}

void __fastcall TForm1::FormCreate(TObject *Sender)
{
  Edit1->Text = "3.14159265358979";
}

 

Delphi Examples: 

{
This example shows how to use the ArcTan and FloatToStr
functions to approximate Pi.
}
procedure TForm1.Button1Click(Sender: TObject);
var
  ex : Extended;
  mystring : String;
begin
  ex := 16 * ArcTan(1/5) - 4 * ArcTan(1/239); // Machin's formula
  mystring := FloatToStr(ex);
  Edit3.Text := mystring;
  Str(ex:25:23, mystring);
  Edit4.Text := mystring;
  mystring := FloatToStrF(ex, ffFixed, 35, 33);
  Edit2.Text := mystring;
  mystring := SysUtils.FormatFloat('#,##0.00000000000000000000000000;;Zero', ex);
  Edit5.Text := mystring;
end;

procedure TForm1.FormCreate(Sender: TObject);
var
  ex : Extended;
  myString : String;
begin
  ex := Pi;
//  mystring := FloatToStr(ex);
//  Str(ex:25:23, mystring);
  mystring := FloatToStrF(ex, ffFixed, 35, 33);
  Edit1.Text := mystring;
end;

 

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!