admin

[系统应用] 常用计算函数

(1)绝对值:

function abs(x);

说明:返回参数的绝对值。

Writeln('a=-10的绝对值=',Abs(a):9:3);

(2)平方函数

function sqr(x:Extended):Extended;(实数)

function sqr(x:Integer):Integer;(整数)

Writeln('b=3,b^2=',Sqr(b):9:3);

(3)平方根函数

function sqrt(x:Extended):Extended;

说明:返回非负数x的平方根

Write('c=16, c的平方根=',Sqrt(c):9:3,-sqrt(c):9:3);

(4)正弦函数(x参数是弧度,即π/2等)

function sin(x:Extended):Extended

(5)余弦函数

function cos(x:Extended):Extended

(6)反正切函数(x(-无穷,+无穷),函数返回值位弧度(-π/2,π/2))

function arctan(x:Extended):Extended

(7)取整函数

function round(x:Extended):Int64

说明:对x进行四舍五入取整

function trunc(x:Extended):Int64

说明:返回最大的且不大于x的整数

(8)指数函数

function exp(x:real):real;

(9)对数函数

function ln(x:real):real;

(10)随机函数

function random[(Range:Integer)];

--------------------- 




#1楼
发帖时间:9天前   |   查看数:0   |   回复数:1
admin

unit TestCalMathMain;

interface

uses
 Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
 Dialogs, cxGraphics, cxControls, cxLookAndFeels, cxLookAndFeelPainters,
 cxContainer, cxEdit, StdCtrls, cxTextEdit, cxMaskEdit, cxSpinEdit, acPNG,
 ExtCtrls;

type
 TForm1 = class(TForm)
   Image1: TImage;
   Label1: TLabel;
   Label2: TLabel;
   Label3: TLabel;
   Label4: TLabel;
   Label5: TLabel;
   cxSpinEdit_S: TcxSpinEdit;
   cxSpinEdit_L: TcxSpinEdit;
   cxSpinEdit_r: TcxSpinEdit;
   cxSpinEdit_σ: TcxSpinEdit;
   cxSpinEdit_T: TcxSpinEdit;
   Button1: TButton;
   Label_d1: TLabel;
   Label_d2: TLabel;
   procedure Button1Click(Sender: TObject);
 private
   { Private declarations }
 public
   { Public declarations }
 end;

var
 Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
 d1, d2: Double;
begin
 d1 := (ln(cxSpinEdit_S.Value / cxSpinEdit_L.Value) + ((cxSpinEdit_r.Value + (0.5 * sqr(cxSpinEdit_σ.Value)))
       * cxSpinEdit_T.Value)) / (cxSpinEdit_σ.Value * sqrt(cxSpinEdit_T.Value));
 Label_d1.Caption := format('d1 = %.4f', [d1]);
 d2 := (ln(cxSpinEdit_S.Value / cxSpinEdit_L.Value) + ((cxSpinEdit_r.Value - (0.5 * sqr(cxSpinEdit_σ.Value)))
       * cxSpinEdit_T.Value)) / (cxSpinEdit_σ.Value * sqrt(cxSpinEdit_T.Value));
 Label_d2.Caption := format('d2 = %.4f', [d2]);
end;

9天前 #2楼
游客组