DelphiBasics
Pi
Function
The mathematical constant System unit
 function Pi():Extended;
Description
The Pi function returns a floating point value giving a useful approximation of the value of Pi.
 
The circumference of a circle Pi * Diameter.
Related commands
CosThe Cosine of a number
ExtendedThe floating point type with the highest capacity and precision
SinThe Sine of a number
TanThe Tangent of a number
 Download this web site as a Windows program.




 
Example code : Get the area and circumference of a circle
var
  myPi : Extended;
  diam : Integer;
begin
  diam := 10;

  // Show circumference and the area of a circle
  // with diameter - 10 cm
  ShowMessage('     Diameter = '+IntToStr(diam));
  ShowMessage('Circumference = '+FloatToStr(Pi*diam));
  ShowMessage('         Area = '+FloatToStr(Pi*(diam/2)*(diam/2)));
end;
Show full unit code
   Diameter = 10
  Circumference = 31.4159265358979
   Area = 78.5398163397448
 
Delphi Programming © Neil Moffatt 2002 - 2022. All rights reserved.  |  Home Page