E
EdwardZhou
Unregistered / Unconfirmed
GUEST, unregistred user!
下面的程序输出什么内容?
procedure TForm1.btn1Click(Sender: TObject);
var
WLLatitudeFZ : double;
WLLatitudeI, WLLatitudeF : Integer;
begin
WLLatitudeFZ := 10.111;
WLLatitudeFZ := StrToFloat(Format('%.2f', [WLLatitudeFZ]));
WLLatitudeI:= Floor(WLLatitudeFZ);
WLLatitudeF:= Floor(Frac(WLLatitudeFZ) * 100);
ShowMessage(IntToStr(WLLatitudeF) + ',' + IntToStr(Floor(Frac(10.11)*100)));
end;
我预期结果是:11,11,因为WLLatitudeFZ=10.11
但是在Delphi7中的结果是:10,11,为什么?
WLLatitudeFZ := StrToFloat(Format('%.2f', [WLLatitudeFZ]));的本意在于只保持小数后两位,可是如果去掉这句话,结果就是11,11了,这又是为什么?
procedure TForm1.btn1Click(Sender: TObject);
var
WLLatitudeFZ : double;
WLLatitudeI, WLLatitudeF : Integer;
begin
WLLatitudeFZ := 10.111;
WLLatitudeFZ := StrToFloat(Format('%.2f', [WLLatitudeFZ]));
WLLatitudeI:= Floor(WLLatitudeFZ);
WLLatitudeF:= Floor(Frac(WLLatitudeFZ) * 100);
ShowMessage(IntToStr(WLLatitudeF) + ',' + IntToStr(Floor(Frac(10.11)*100)));
end;
我预期结果是:11,11,因为WLLatitudeFZ=10.11
但是在Delphi7中的结果是:10,11,为什么?
WLLatitudeFZ := StrToFloat(Format('%.2f', [WLLatitudeFZ]));的本意在于只保持小数后两位,可是如果去掉这句话,结果就是11,11了,这又是为什么?