怎么全文检索老是不能用?记不得怎么转换real为integer

解决方案 »

  1.   

    ShowMessage(IntToStr(Trunc(temp)));//验证
    所以可以用Trunc(X)函数
      

  2.   

    Trunc function
    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.