送分题:请问浮点数取整的函数是什么?
请问浮点数取整的函数是什么?
round()只能四舍五入,不能取整,
问题点数:10、回复次数:2Top
1 楼ePing(是谁动了我的CSDN的ID?)回复于 2001-02-03 11:28:00 得分 10
Trunc函数
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;Top
2 楼ePing(是谁动了我的CSDN的ID?)回复于 2001-02-03 11:28:00 得分 0
Truncates a real number to an integer.
Unit
System
Category
arithmetic routines
function Trunc(X: Extended): Int64;
Description
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. Top




