我一般在串列埠通訊的時候用byte比較多。
byte:範圍是0到255的整數。只要在這個範圍的內的都可以用這個型別。
Delphi中如何將一個extended型強制轉換為integer型
━━━━━━━━━━━━━━━━━━━━━━━━━━
functionRound(X:Extended):Int64;//四捨五入,測試可行
functionTrunc(X:Extended):Int64;//取整
functionInt(X:Extended):Extended;
round四捨五入
trunc去掉小數點後面的部分取整
procedureTForm1.BitBtn1Click(Sender:TObject);
var
a:extended;
b:int64;
begin
a:=2132123323211.005;
b:=round(a);
caption:=currtostr(b);
end;
不知道是不是你的意思?
如果不做舍入,用Trunc()
procedureTForm1.Button1Click(Sender:TObject);
vara:extended;
b:integer;
a:=strtofloat(edit1.text);
b:=trunc(a);
edit2.TExt:=inttostr(b);
我一般在串列埠通訊的時候用byte比較多。
byte:範圍是0到255的整數。只要在這個範圍的內的都可以用這個型別。
Delphi中如何將一個extended型強制轉換為integer型
━━━━━━━━━━━━━━━━━━━━━━━━━━
functionRound(X:Extended):Int64;//四捨五入,測試可行
functionTrunc(X:Extended):Int64;//取整
functionInt(X:Extended):Extended;
round四捨五入
trunc去掉小數點後面的部分取整
━━━━━━━━━━━━━━━━━━━━━━━━━━
procedureTForm1.BitBtn1Click(Sender:TObject);
var
a:extended;
b:int64;
begin
a:=2132123323211.005;
b:=round(a);
caption:=currtostr(b);
end;
不知道是不是你的意思?
━━━━━━━━━━━━━━━━━━━━━━━━━━
如果不做舍入,用Trunc()
procedureTForm1.Button1Click(Sender:TObject);
vara:extended;
b:integer;
begin
a:=strtofloat(edit1.text);
b:=trunc(a);
edit2.TExt:=inttostr(b);
end;