Returns 3.1415926535897932385.
function Pi: Extended;
Extended Pi();
Use Pi in Delphi code to represent the mathematical value pi, the ratio of a circle's circumference to its diameter. Pi is approximated as 3.1415926535897932385.
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!
|