大神們好 能問個問題嗎
Src:array [0..11] of Byte;
Src里存了12個數字
怎么把Src里的數字一個個轉換成二進制賦值給一個個的string嗎
string str0=src【0】的二進制
string str1=src【1】的二進制
。
。
。
uj5u.com熱心網友回復:
function ByteToBitStr(Value: Byte): String;
var
I: Byte;
begin
Result := '00000000';
if Value <> 0 then
begin
for I := 8 downto 1 do
begin
if (Value and 1) = 1 then
Result[I] := '1'
else
Result[I] := '0';
Value := (Value shr 1);
end;
end;
end;
uj5u.com熱心網友回復:
var
lStr: AnsiString;
lBytes: Array[0..11] of Byte;
lIndex, lSI: Integer;
begin
lBytes[3] := 66;
lBytes[1] := 2;
lBytes[9] := 89;
SetLength(lStr, Length(lBytes) * 2);
lSI := 1;
for lIndex := Low(LBytes) to High(lBytes) do
begin
Move(AnsiString(IntToHex(lBytes[lIndex]))[1], lStr[lSI], 2);
Inc(lSI, 2);
end;
ShowMessage(lStr);
end;
uj5u.com熱心網友回復:
謝謝大神 能在問下 二進制 怎么轉換成十進制 嗎 謝謝
uj5u.com熱心網友回復:
二進制換成十進制, 這僅涉及編程的最基本的知識,你自己應該可以寫出來轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/32627.html
標籤:VCL組件開發及應用
上一篇:Delphi問題
下一篇:合并單元格
