猿问

s:=floattostr(a5) ;这一行出问题了,想不通,咋整?

var a1,a2,a3,a4,a5 : double ;
s:string;
begin

a1:= strtofloat(trim(edit1.Text ));
a2:=strtofloat (trim(edit2.Text ));
a3:=strtofloat (trim(edit3.Text ));
a4:=strtofloat (trim(edit4.Text ));
try
if RadioButton1.Checked=true then
a5:=((a1 * 2) / a3*a4+a2)*1.1

s:=floattostr(a5) ;
showmessage(s);

尚方宝剑之说
浏览 125回答 3
3回答

喵喵时光机

就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;begina1:=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看看是不是其他地方造成的错误

茅侃侃

floattostr没有这个函数浮点转字符format('%e',[a5])

蛊毒传说

caption := FormatFloat('###,##.###', 2340283.23423432);caption := Format('%.3f',[345435.345845]);
随时随地看视频慕课网APP

相关分类

Java
我要回答