Ml2:=Ml / (amt1+abs(amt2))
Ml,ml2,amt1,amt2均为real,从表中读出均为asfloat,执行上述公式时出错:
invalid floating point operation,
帮忙顶下,谢谢了

解决方案 »

  1.   

    小数部分在输出的时候决定,如下:
    procedure TForm1.Button1Click(Sender: TObject);
    var Ml,ml2,amt1,amt2:Real;
    begin
     Ml:=124325325;
     amt1:=545665;
     amt2:=156758.999;
     Ml2:=Ml /(amt1+abs(amt2));
     ShowMessage(FormatFloat('000.000',ml2));
    end;
      

  2.   

    abs  参数能不能为小数
      

  3.   

    abs没错,可以是小数,问题出在你的除数上面
    ////////////////////////////
    function Abs(X);DescriptionAbs returns the absolute value of the argument, X.X is an integer-type or real-type expression.////////////////////////////
    执行 Ml2:=Ml /(amt1+abs(amt2));前要判断(amt1+abs(amt2))<>0才行。
    if (amt1+abs(amt2))<>0 then
        Ml2:=Ml /(amt1+abs(amt2))