개발자의 노트
반응형

설명은 따로 없습니다. 아래 코드를 참고하세요.


function BinToInt(const Bin: string): Integer;

var

  I, Len: Integer;

begin

  Result := 0;

  Len := Length(Bin);

  for i := Len downto 1 do

    if Bin[I] = '1' then

      Result := Result + (1 shl (Len - I));

end;


 

function HexToBin(const Hexadecimal: string): string;

const

  BCD: array[0..15] of string =

  ('0000', '0001', '0010', '0011', '0100', '0101', '0110', '0111',

    '1000', '1001', '1010', '1011', '1100', '1101', '1110', '1111');

var

  I: integer;

begin

  for I := Length(Hexadecimal) downto 1 do

    Result := BCD[StrToInt('$' + Hexadecimal[I])] + Result;

end;


profile

개발자의 노트

@곽코딩

포스팅이 좋았다면 "좋아요❤️" 또는 "구독👍🏻" 해주세요!