有这样的函数吗:
1.0000~01取整为2
3.999~999取整为4
4.81928474取整为5
5.0取整为5
5.1取整为6
.....??

解决方案 »

  1.   


    i := (m)div(n);
    i1 := (m)mod(n);
    if i1>0 then
      i := i+1;
      

  2.   

    小数位数没有限制。关于取模和取余我都不知道怎么弄了。MOD和Div1.0000....01取整为2
    3.999.....999取整为4
    4.8192.23238474取整为5
    5.0取整为5
    5.1取整为6
      

  3.   

    if Frac(X) > 0.0000000 then
      result := Int(X) + 1
    else
      result := Int(X);
      

  4.   

    现成的函数:ceil.(天花板)
    如果取下限整数用FLOOR(地板)
    楼主太懒惰了,这样的问题去HELP里找一下就好了。
      

  5.   

    Rounds variables up toward positive infinity.UnitMath
    HELP里的详细说明如下:
    CategoryArithmetic routinesDelphi syntax:function Ceil(const X: Extended):Integer;C++ syntax:extern PACKAGE int __fastcall Ceil(const Extended X);DescriptionCall Ceil to obtain the lowest integer greater than or equal to X. The absolute value of X must be less than MaxInt.  For example:Ceil(-2.8) = -2Ceil(2.8) = 3Ceil(-1.0) = -1
      

  6.   

    没有上面那么麻烦,楼主可以使用Trunc函数实现,该函数得到的是实数的整数部分,根据你的要求再加1既可,即 y=trunc(x)+1
      

  7.   

    function MyRound(Value: Extended):Int64;
    begin
      if abs(Value - Trunc(Value)) > 0 then
        Result := Trunc(Value) + 1
      else
        Result := Trunc(Value);
    end;