Visual Basic, C & C++
Delphi 분류

델파이에서 16진수 문자열을 2진수 문자열로 바꾸기

컨텐츠 정보

본문

function HexToBin(sHex: string): string;
var
  iHex, iDigit : integer;
begin
  iDigit := Length(sHex) * 4;
  iHex := StrToInt('$' + sHex);

  result := StringOfChar('0', iDigit);
  while iHex > 0 do begin
    if (iHex and 1) = 1 then
      result[iDigit] := '1';
    dec(iDigit) ;
    iHex := iHex shr 1;
  end;
end;

관련자료

댓글 0
등록된 댓글이 없습니다.
Today's proverb
생각은 자유롭고 독립적인 듯 보이지만 인간은 생각보다 더 강한 것을 가지고 있다. 그것은 생각을 인도할 수 있는 능력이다.