개발자의 노트
반응형

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


const

  HexChars: array[0..15] of Char = ('0', '1', '2', '3', '4', '5',

                                    '6', '7', '8', '9', 'a', 'b',

                                    'c', 'd', 'e', 'f');


function IntToHex(Int: Int64; IntSize: Byte): string;

var

  n: Byte;

begin

  Result := '';

  for n := 0 to IntSize - 1 do

  begin

    Result := HexChars[Int and $F] + Result;

    Int := Int shr $4;

  end;

end;


 

function HexToInt(const Value: string): LongWord;

const

  HexStr: String = '0123456789abcdef';

var

  i: Word;

begin

  Result := 0;

  if Value = '' then Exit;

  for i := 1 to Length(Value) do

    Inc(Result, (Pos(Value[i], HexStr) - 1) shl ((Length(Value) - i) shl 2));

end;



profile

개발자의 노트

@곽코딩

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