如题

解决方案 »

  1.   

    function xxxx(value:extended):int64;
    begin
      if value-trunc(value)>=0.5 then 
        result:=trunc(value)+1
      else
        result:=trunc(value)
    end;
      

  2.   

    Round                       函数         将实数值舍入为整型值
      

  3.   

    四舍五入到百分位:Round(n*100)/100; //输出为浮点数n 为操作数,其它情形照搬即可。
      

  4.   


    这么简单也问
    用format函数
      

  5.   

    round(浮点数):integer;
    取最小整数。Floor(浮点数):integer;
      

  6.   

    最好不用round,有时会算错!
      

  7.   

    自产函数,可以借鉴
    //==============================================================================
    //标准四舍五入进位**************************************************************
    //==============================================================================
    function StanRoundTo(const AValue: Double; const ADigit: TRoundToRange = -2): Double;
    var LFactor: Double;
    begin
      LFactor := IntPower(10, ADigit);
      Result := (Trunc(AValue / LFactor) + IfThen(Frac(AValue / LFactor)>=0.4999, 1, 0)) * LFactor;
    end;
    //==============================================================================
    //强制向上进位******************************************************************
    //==============================================================================
    function OverRoundTo(const AValue: Double; const ADigit: TRoundToRange = -2): Double;
    var LFactor: Double;
    begin
      LFactor := IntPower(10, ADigit);
      Result := (Trunc(AValue / LFactor) + IfThen(Frac(AValue / LFactor)>=0.0999, 1, 0)) * LFactor;
    end;//==============================================================================
    //强制向下进位******************************************************************
    //==============================================================================
    function DownRoundTo(const AValue: Double; const ADigit: TRoundToRange = -2): Double;
    var LFactor: Double;
    begin
      LFactor := IntPower(10, ADigit);
      Result := (Trunc(AValue / LFactor) + IfThen(Frac(AValue / LFactor)>=0.9999, 1, 0)) * LFactor;
    end;