注意,DELPHI中的round()有问题的,如round(2.5)=2而不是3,可能是实数存储的问题,最好用
round(2.5+0.01)才能为3

解决方案 »

  1.   

    var
      x: Float...
      x := 3.1415926;
      x := Trunc(x * 100 + .5) / 100;  // 100保留2位,1000保留3位, etc...
      

  2.   

    你不想4舍5入
    var
      r1, r2: double;begin
      r1 := 234.451;
      r2 := StrToFloat(formatFloat('.00', r1));
      if r2 - r1 > 0 then r2 := r2 - 0.01;
      showmessage(Floattostr(r2));
      result := r2;//结果 
    end;想4舍5入
      r2 := StrToFloat(formatFloat('.00', r1));
      showmessage(Floattostr(r2));
      result := r2;//结果 
    end;
      

  3.   

    你想4舍5入procedure TForm1.Button2Click(Sender: TObject);
    var
      r1, r2: double;begin
      r1 := 234.451;
      r2 := StrToFloat(formatFloat('.00', r1));
      if r2 - r1 > 0 then r2 := r2 - 0.01;
      showmessage(Floattostr(r2));
      result := r2;//r2示结果
    end;你不想4舍5入
    var
      r2: double;begin
      r2 := StrToFloat(formatFloat('.00', r2));
      showmessage(Floattostr(r2));
    end;
    刚才没传上去。
      

  4.   

    r1:=234.456;
    r2:=floattoint(r1*100)/100;
    result=r2;
      

  5.   

    结果:=StrtoFloat(Format('%0.0f',[strtofloat(Format('%0.1f',[你的数为Float型]))]));
      

  6.   

    RxCalcEdit1.value:=StrtoFloat(Format('%0.0f',[strtofloat(Format('%0.1f',[RxCalcEdit1.value]))]));