Round(20.356,-2);(函数名称可能记错了,你查一下Delphi帮助)
第二个参数表示精确位数,0表示个位,1表示十位,-1表示十分位

解决方案 »

  1.   

    label1.Caption := Format('%5.2f',[20.356]);
      

  2.   

    补充:我记起了函数原形是:RoundTo;
      

  3.   

    上面的,
    也可以用formatfloat('0.00',20.356);
    不过返回值是字符的
      

  4.   

    function RoundTo(const AValue: Double; const ADigit: TRoundToRange): Double;DescriptionCall RoundTo to round AValue to a specified power of ten.AValue is the value to round.ADigit indicates the power of ten to which you want AValue rounded. It can be any value from ?7 to 37 (inclusive).RoundTo uses 揃anker抯 Rounding?to determine how to round values that are exactly midway between the two values that have the desired number of significant digits. This method rounds to an even number in the case that AValue is not nearer to either value.The following examples illustrate the use of RoundTo: Expression ValueRoundTo(1234567, 3) 1234000
    RoundTo(1.234, -2) 1.23
    RoundTo(1.235, -2) 1.24
    RoundTo(1.245, -2) 1.24Note: The behavior of RoundTo can be affected by the Set8087CW procedure or SetRoundMode function.
      

  5.   

    是我发帖子错了吗?我找不到RoundTo()这个函数  我用的是DELPHI 不知各位给我的答案是DELPHI里面的吗?
      

  6.   

    笨办法:先乘power(10,n)
    再round
    再除以power(10,n)
      

  7.   

    formatfloat('0.00',20.356);
    round()都可以
      

  8.   

    在delphi里可以四舍五入的函数有round,trunc,roundto,前面两个返回的是Int64,后面一个返回double。用round返回的整形一定是个偶数,这个要注意一下,否则可能得不到你要的结果。
    具体的差别你可以查看delphi自带的帮助文件,讲得很清楚的
      

  9.   

    谁有ROUNDTO函数的原码  我这没有 能不能贴上去
      

  10.   

    ROUNDTO()在delphi6中才有。同意alexxing(赤铸)的方法
      

  11.   

    用roundto 需要前面 加上use math, 否则会找不到roundto
      

  12.   


    12.345×10的3次方用DELPHI怎么表达?