如 0.98 取得的是 0
   3.21 取得的是 3多谢了.

解决方案 »

  1.   

    这样用就可以了
    round(int(x))
      

  2.   

      showmessage(floattostr(trunc(strtofloat('0.98'))));
      showmessage(floattostr(trunc(strtofloat('3.28'))));
      showmessage(floattostr(trunc(strtofloat('3.98'))));
      

  3.   

    补充一下:floor,round,trunc,formatfloat这几个你都可以看看,都是处理数字的函数
      

  4.   

    floor 直接往小的取
    trunc 直接切下整数 
    ceil 直接往大的取
      

  5.   

    FormatFloat('0',变量)
    Format(%.2f,[变量]) 
      

  6.   

    function Round(X: Extended): Int64;//四舍五入 
    function Trunc(X: Extended): Int64;//将小数无条件舍去
        floor 和 ceil 是 math unit 里的函数,使用前要先 Uses Math。
        trunc 和 round 是 system unit 里的函数,缺省就可以用 。
        floor 直接往小的取,比如 floor(-123.55)=-124,floor(123.55)=123
        trunc 直接切下整数,比如 trunc(-123.55)=-123, floor(123.55)=123
        ceil 直接往大的取,比如 ceil(-123.55)=-123, ceil(123.55)=124
        round 计算四舍五入,比如 round(-123.55)=-124,round(123.55)=124
    Value1:=roundto(value1,-2);   
      

  7.   

    trunc
    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, mbOk);
    end;
      

  8.   

    如果只取第一位...用INT...或把FLOAT转字符,取小数点前几位.
    呵呵.
      

  9.   


    FUNCTION StrLeft(Str,SubStr:STRING):STRING;
    VAR V_POS:INTEGER;
    begin
      V_POS:=POS(SubStr,Str);
      if V_POS=0 then
        result:=Str
      else
        RESULT:=COPY(Str,1,V_POS-1);
    end;自己写的一个函数。。通用的
    如:
    StrLeft('kmk.MC','.')='kmk';
    StrLeft(floattostr(2.09),'.')='2';