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
提交
取消