怎么全文检索老是不能用?记不得怎么转换real为integer
解决方案 »
- 如何固定Form焦点使其不关闭不能点击其他Form
- 怎么改回Main Form
- 怎樣處理 datetime 的1899/12/30 的問題
- 我用API函数CreateFile创建了一个文件,然后我怎么访问它?
- 请教:在程序中写SQL语句时引号用法的问题
- 难题中的极品:Excel文件损坏,用Excel打开会有文件是只读或服务器没有响应的提示.谁有办法修复就给高分.2002年12月19日结帖.
- 在quickrep中, 如果一个记录能自动换行,怎么动态调整相应的QRShape的长度啊?
- 好看的笑话,笑死俺了!问题:listview如何加入图片?
- 将数据导出到Excel中
- 请问,在DELPHI中如何进行16进制运算,数据类型要如何定义?
- 如何在delphi里打开一个txt文件
- ▓▓▓请问怎么用delphi获取网页中嵌入的Meaiaplayer的URL值?▓▓▓
所以可以用Trunc(X)函数
Truncates a real number to an integer.
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;
function Trunc(X: Extended): Int64;DescriptionThe 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.
_____________________________Int function
Returns the integer part of a real number.
var R: Real;
begin
R := Int(123.456); { 123.0 }
R := Int(-123.456); { -123.0 }
end;
function Int(X: Extended): Extended;DescriptionInt returns the integer part of X; that is, X rounded toward zero. X is a real-type expression.
Round function
Returns the value of X rounded to the nearest whole number.
var S, T: string;begin Str(1.4:2:1, T);
S := T + ' rounds to ' + IntToStr(Round(1.4)) + #13#10;
Str(1.5:2:1, T);
S := S + T + ' rounds to ' + IntToStr(Round(1.5)) + #13#10;
Str(-1.4:2:1, T);
S := S + T + ' rounds to ' + IntToStr(Round(-1.4)) + #13#10;
Str(-1.5:2:1, T);
S := S + T + ' rounds to ' + IntToStr(Round(-1.5));
MessageDlg(S, mtInformation, [mbOk], 0);
end;
______________________________________function Round(X: Extended): Int64;DescriptionThe Round function rounds a real-type value to an integer-type value.X is a real-type expression. Round returns an Int64 value that is the value of X rounded to the nearest whole number. If X is exactly halfway between two whole numbers, the result is always the even number.If the rounded value of X is not within the Int64 range, a run-time error is generated, which can be handled using the EInvalidOp exception.