var a1,a2,a3,a4,a5 : double ;s:string;begina1:= strtofloat(trim(edit1.Text ));a2:=strtofloat (trim(edit2.Text ));a3:=strtofloat (trim(edit3.Text ));a4:=strtofloat (trim(edit4.Text ));tryif RadioButton1.Checked=true thena5:=((a1 * 2) / a3*a4+a2)*1.1s:=floattostr(a5) ;showmessage(s);
3 回答
喵喵时光机
TA贡献1846条经验 获得超7个赞
就s:=floattostr(a5);这一行代码本身是没问题的
function FloatToStr(Value: Extended): string; overload;
function FloatToStr(Value: Extended; const FormatSettings: TFormatSettings): string; overload;
我简单测试了你的程序,
procedure TForm1.btn1Click(Sender: TObject);
var a1,a2,a3,a4,a5 : double ;
s:string;
begin
a1:=1.0;
a2:=3.0;
a3:=2.0;
a4:=4.0;
a5:=((a1 * 2) / a3*a4+a2)*1.1;
s:=floattostr(a5) ;
showmessage(s);
end;
运行结果显示了7.7
看看是不是其他地方造成的错误
蛊毒传说
TA贡献1895条经验 获得超3个赞
caption := FormatFloat('###,##.###', 2340283.23423432);
caption := Format('%.3f',[345435.345845]);
添加回答
举报
0/150
提交
取消