Delphi中的算术运算函数
2002-09-10 13:38
585 查看
Delphi中的算术运算函数
以下内容为编编程网站诸网友共同翻译的结果,如需转载,请注明出处:http://www.togetherdev.com,如果您对翻译Delphi的函数有兴趣,可登录编编程网站,如果对翻译的内容有什么看法,可以在回帖或在编编程网站中提出。
以下内容为编编程网站诸网友共同翻译的结果,如需转载,请注明出处:http://www.togetherdev.com,如果您对翻译Delphi的函数有兴趣,可登录
函数名 | ABS |
简要介绍: | Returnsanabsolutevalue.(取绝对值) |
所属单元: | System |
定义: | functionAbs(X); |
详细解释: | Absreturnstheabsolutevalueoftheargument,X. Xisaninteger-typeorreal-typeexpression. (Abs函数用于返回变量X的绝对值,X可以是一个整形的变量或实数型的变量) |
函数名 | ceil |
简要介绍: | Roundsvariablesuptowardpositiveinfinity. |
所属单元: | Math |
定义: | functionCeil(X:Extended):Integer |
详细解释: | CallCeiltoobtainthelowestintegergreaterthanorequaltoX.TheabsolutevalueofXmustbelessthanMaxInt.Forexample: Ceil(-2.8)=-2 Ceil(2.8)=3 Ceil(-1.0)=-1 (调用ceil函数,返回大于或等于x的最小整数值。X的绝对值一定要小于最大整数值。例如: Ceil(-2.8)=-2 Ceil(2.8)=3 Ceil(-1.0)=-1) |
函数名 | Exp |
简要介绍: | ReturnstheexponentialofX.(Exp函数返回自然对数基底E的X次幂。) |
所属单元: | System |
定义: | functionExp(X:Real):Real; |
详细解释: | ExpreturnsthevalueoferaisedtothepowerofX,whereeisthebaseofthenaturallogarithms. (Exp返回e的X次幂的值,其中e是一个自然对数基底。) |
范例: | var e:real; S:string; begin e:=Exp(1.0); Str(ln(e):3:2,S); S:='e='+FloatToStr(e)+';ln(e)='+S; Canvas.TextOut(10,10,S); end; |
函数名 | Floor |
简要介绍: | Roundsvariablestowardnegativeinfinity.(取小于给定值的最大整数) |
所属单元: | Math |
定义: | functionFloor(X:Extended):Integer; |
详细解释: | CallFloortoobtainthehighestintegerlessthanorequaltoX.Forexample: Floor(-2.8)=-3 Floor(2.8)=2 Floor(-1.0)=-1 Note:TheabsolutevalueofXmustbelessthanMaxInt. (使用Floor函数以取得小于等于X的最大的整数,如: Floor(-2.8)=-3 Floor(2.8)=2 Floor(-1.0)=-1 注意:X的绝对值必须小于整形数的最大值) |
函数名 | Frac |
简要介绍: | Returnsthefractionalpartofarealnumber(返回一个实数的小数部分) |
所属单元: | System |
定义: | functionFrac(X:Extended):Extended; |
详细解释: | TheFracfunctionreturnsthefractionalpartoftheargumentX. Xisareal-typeexpression.TheresultisthefractionalpartofX;thatis,Frac(X)=X-Int(X). (Frac函数返回参数X的小数部分,X是一个实型数,该函数的作用等价于Frac(X)=X-Int(X)。) |
范例: | var a,b:Real; begin a:=1.54; b:=frac(a); end; 此时,a=1.54,b=0.54 |
函数名 | Frexp |
简要介绍: | SeparatestheMantissaandExponentofX(分解开X的尾数和指数。) |
所属单元: | Math |
定义: | procedureFrexp(X:Extended;varMantissa:Extended;varExponent:Integer)register; |
详细解释: | FrexpreturnsthemantissaofXasMantissaandtheexponentasExponent.(Frexp函数返回X的尾数用变量Mantissa和指数用变量Exponent)。 |
函数名 | int |
简要介绍: | Returnstheintegerpartofarealnumber.(返回一个实数类型的整数部分) |
所属单元: | System |
定义: | functionInt(X:Extended):Extended; |
详细解释: | IntreturnstheintegerpartofX;thatis,Xroundedtowardzero.Xisareal-typeexpression.(Int函数返回参数X的整数部分,X为实数类型,函数结果为X经过负向舍入(向0舍入)实数。) |
范例: | var R:Real; begin R:=Int(123.456);{123.0} R:=Int(-123.456);{-123.0} end; |
函数名 | Intpower |
简要介绍: | Calculatestheintegralpowerofabasevalue.(计算基数的整数幂。) |
所属单元: | Math |
定义: | functionIntPower(Base:Extended;Exponent:Integer):Extendedregister; |
详细解释: | IntPowerraisesBasetothepowerspecifiedbyExponent (计算基数的整数幂。base为基数,Exponent为指数) |
范例: | |
函数名 | Ldexp |
简要介绍: | CalculatesX*(2**P) |
所属单元: | Math |
定义: | functionLdexp(X:Extended;P:Integer):Extendedregister; |
详细解释: | LdexpreturnsXtimes(2tothepowerofP). (Ldexp计算X*(2**P),返回X的(2的P次幂)次幂。) |
函数名 | Max |
简要介绍: | Returnsthegreateroftwonumericvalues.(取两个数中的最大值) |
所属单元: | Math |
定义: | functionMax(A,B:Integer):Integer;overload; |
详细解释: | CallMaxtocomparetwonumericvalues.Maxreturnsthegreatervalueofthetwo. (返回两个数值中的最大值。调用Max比较两个数值。它返回二者中较大的一个值。) |
函数名 | Min |
简要介绍: | Returnsthelesseroftwonumericvalues.(取两个数的最小值) |
所属单元: | Math |
定义: | functionMin(A,B:Integer):Integer;overload; functionMin(A,B:Int64):Int64;overload; functionMin(A,B:Single):Single;overload; functionMin(A,B:Double):Double;overload; functionMin(A,B:Extended):Extended;overload; |
详细解释: | CallMintocomparetwonumericvalues.Minreturnsthesmallervalueofthetwo. (返回两个数值中的最小值。调用Max比较两个数值,它返回二者中较小的一个值。) |
函数名 | pi |
简要介绍: | Returns3.1415926535897932385.(返回3.1415926535897932385.) |
所属单元: | System |
定义: | functionPi:Extended; |
详细解释: | UsePiinmathematicalcalculationsthatrequirepi,theratioofacircle'scircumferencetoitsdiameter.Piisapproximatedas3.1415926535897932385. (使用Pi函数精确计算返回圆周率Pi,圆周率是一个圆的周长除以它的直径。Pi的值近似于3.1415926535897932385.) |
函数名 | poly(本条翻译无把握) |
简要介绍: | EvaluatesauniformpolynomialofonevariableatthevalueX. |
所属单元: | Math |
定义: | functionPoly(X:Extended;constCoefficients:arrayofDouble):Extended; |
详细解释: | CallPolytoevaluatethepolynomialrepresentedbytheCoefficientsparameteratthepointwherethevariableequalsthevalueoftheXparameter.ThecoefficientsareorderedinincreasingpowersofX: Coefficients[0]+Coefficients[1]*X+...+Coefficients *(X**N) (Poly估计一个变量在同一多项式的X值。调用Poly评估由Coefficients参数表达的多项式在一位置的值等同于X参数的值。参数是顺序的以X的幂增加:Coefficients[0]+ coefficients[1]*X+…..+Cofficients *[X**N]) |
函数名 | power |
简要介绍: | RaisesBasetoanypower.(取一个实数的幂) |
所属单元: | Math |
定义: | functionPower(Base,Exponent:Extended):Extended; |
详细解释: | PowerraisesBasetoanypower.ForfractionalexponentsorexponentsgreaterthanMaxInt,Basemustbegreaterthan0. (返回一个实数的幂。当指数Exponent为小数或大于MaxInt时,底数Base必须大于0.) |
函数名 | Round |
简要介绍: | ReturnsthevalueofXroundedtothenearestwholenumber.(对一个实数进行四舍五入) |
所属单元: | System |
定义: | functionRound(X:Extended):Int64; |
详细解释: | TheRoundfunctionroundsareal-typevaluetoaninteger-typevalue. Xisareal-typeexpression.RoundreturnsanInt64valuethatisthevalueofXroundedtothenearestwholenumber.IfXisexactlyhalfwaybetweentwowholenumbers,theresultisalwaystheevennumber. IftheroundedvalueofXisnotwithintheInt64range,arun-timeerrorisgenerated,whichcanbehandledusingtheEInvalidOpexception. (Round返回X向最近整数值的舍入。 函数将一个实型值舍入为一个整型值。X是一个实型表达式。Round返回一个长整型值,是离X最近的整数值。如果X是两个整数值的正中间,结果是绝对值最大的一个。如果X的舍入值不是在长整型范围内,一个运行时间错误将产生,可以使用EinvalidOp异常来处理) |
范例: | var |
函数名 | Sqr |
简要介绍: | Returnsthesquareofanumber.(取给定值的平方) |
所属单元: | System |
定义: | functionSqr(X:Extended):Extended; |
详细解释: | TheSqrfunctionreturnsthesquareoftheargument. Xisafloating-pointexpression.Theresult,ofthesametypeasX,isthesquareofX,orX*X. (Sqr返回X得平方值,X是一个浮点型的数,返回值的类型与X相同,值为X*X) |
范例: | var S,Temp:string; begin Str(Sqr(5.0):3:1,Temp); S:='5squaredis'+Temp+#13#10; Str(Sqrt(2.0):5:4,Temp); S:=S+'Thesquarerootof2is'+Temp; MessageDlg(S,mtInformation,[mbOk],0); end; |
函数名 | sqrt |
简要介绍: | ReturnsthesquarerootofX. |
所属单元: | System |
定义: | functionSqrt(X:Extended):Extended; |
详细解释: | Xisafloating-pointexpression.TheresultisthesquarerootofX. (取X的平方根,X是一个浮点数,返回值也是个浮点数) |
范例: | var S,Temp:string; begin Str(Sqr(5.0):3:1,Temp); S:='5squaredis'+Temp+#13#10; Str(Sqrt(2.0):5:4,Temp); S:=S+'Thesquarerootof2is'+Temp; MessageDlg(S,mtInformation,[mbOk],0); end; |
函数名 | Trunc |
简要介绍: | Truncatesarealnumbertoaninteger.(截取一个实数的整数部分) |
所属单元: | System |
定义: | functionTrunc(X:Extended):Int64; |
详细解释: | TheTruncfunctiontruncatesareal-typevaluetoaninteger-typevalue.Xisareal-typeexpression.TruncreturnsanInt64valuethatisthevalueofXroundedtowardzero. IfthetruncatedvalueofXisnotwithintheInt64range,anEInvalidOpexceptionisraised. |
范例: | var S,T:string; begin Str(1.4:2:1,T); S:=T+'Truncsto'+IntToStr(Trunc(1.4))+#13#10; Str(1.5:2:1,T); S:=S+T+'Truncsto'+IntToStr(Trunc(1.5))+#13#10; Str(-1.4:2:1,T); S:=S+T+'Truncsto'+IntToStr(Trunc(-1.4))+#13#10; Str(-1.5:2:1,T); S:=S+T+'Truncsto'+IntToStr(Trunc(-1.5)); MessageDlg(S,mtInformation,[mbOk],0); end; |
相关文章推荐
- Delphi中MediaPlayer控件的一个Bug即修复
- Delphi之数组
- Delphi制作数据感知控件之浮想联翩
- 个性化Folder Icon(Delphi)
- Delphi 中面向对象编程之我见
- 软件登录的几种实现方法
- 使用Delphi,SDK编写Windows简单程序
- 一个金融应用项目的总结
- 在Delphi编程中获取操作系统信息
- delphi中的时间操作技术(2)
- 使用Windows消息控制Winamp(Delphi)
- 在Delphi中捕获控制台程序的输出
- 用Delphi编写涂鸦桌面的小程序
- BCB/Delphi ActiveForm发布全攻略
- delphi中的时间操作技术(1)
- Internet worm入门教程
- Delphi 元件設計初步(一)
- 使用Delphi 發展商業物件
- Delphi版OpenGL样例代码导游
- 《Delphi高手突破》第0章(预览版)——关于本书