Mega Code Archive

 
Categories / Delphi / Functions
 

Pi - 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 Cos The Cosine of a number Extended The floating point type with the highest capacity and precision Sin The Sine of a number Tan The Tangent of a number 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