手机站
网通分站
电信主站
密 码:
用户名:
当前位置 : 主页>程序设计>delphi>列表

Delphi中的算术运算函数

来源:互联网 作者:西部数码 时间:2008-04-09
西部数码-全国虚拟主机10强!40余项虚拟主机管理功能,全国领先!双线多线虚拟主机南北访问畅通无阻!免费赠送企业邮局,.CN域名,自助建站480元起,免费试用7天,满意再付款! P4主机租用799元/月.月付免压金!

The Sqr function returns the square of the argument.

X is a floating-point expression. The result, of the same type as X, is the square of X, or X*X.
(Sqr返回X得平方值,X是一个浮点型的数,返回值的类型与X 相同,值为X*X)

范例: var
S, Temp: string;
begin
Str(Sqr(5.0):3:1, Temp);
S := ''''5 squared is '''' Temp #13#10;
Str(Sqrt(2.0):5:4, Temp);
S := S ''''The square root of 2 is '''' Temp;
MessageDlg(S, mtInformation, [mbOk], 0);
end;

返回

函数名 sqrt 简要介绍: Returns the square root of X. 所属单元: System 定义: function Sqrt(X: Extended): Extended; 详细解释:

X is a floating-point expression. The result is the square root of X.
(取X的平方根,X是一个浮点数,返回值也是个浮点数)

范例: var
S, Temp: string;
begin
Str(Sqr(5.0):3:1, Temp);
S := ''''5 squared is '''' Temp #13#10;
Str(Sqrt(2.0):5:4, Temp);
S := S ''''The square root of 2 is '''' Temp;
MessageDlg(S, mtInformation, [mbOk], 0);
end;

返回

函数名
Trunc 简要介绍: Truncates a real number to an integer.(截取一个实数的整数部分) 所属单元: System 定义: function Trunc(X: Extended): Int64; 详细解释:

The Trunc function truncates a real-type value to an integer-type value. X is a real-type expression. Trunc returns an Int64 value that is the value of X rounded toward zero.

If the truncated value of X is not within the Int64 range, an EInvalidOp exception is raised.

范例: var
S, T: string;
begin
Str(1.4:2:1, T);
S := T '''' Truncs to '''' IntToStr(Trunc(1.4)) #13#10;
Str(1.5:2:1, T);
S := S T '''' Truncs to '''' IntToStr(Trunc(1.5)) #13#10;
Str(-1.4:2:1, T);
S := S T '''' Truncs to '''' IntToStr(Trunc(-1.4)) #13#10;
Str(-1.5:2:1, T);
S := S T '''' Truncs to '''' IntToStr(Trunc(-1.5));
MessageDlg(S, mtInformation, [mbOk], 0);
end;

文章整理:西部数码--专业提供域名注册虚拟主机服务
http://www.west263.com
以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢!