Q&A

  • 15line 소스분석좀 부탁합니다.
소스분석좀 해주세요..

integer형(32bit)을 64bit hex값으로 변환하는것 같은데..

u,uh,ul의 사용에대해 모르겠습니다.

고수님들의 말씀 기다리겠습니다. ^.^*



Function Int642Hex(nFmt: Int64): String;

var

z: Integer;

u, uh, ul: Byte;

Begin

result := '';

for z := 7 downto 0 do Begin

u := (nFmt shr (z * 8)) and $FF;

uh := (u shr 4) and $F;

ul := u and $F;

if uh >= 10 Then result := Result + Chr(Byte('A')+uh-10)

else result := Result + Chr(Byte('0')+uh);

if ul >= 10 Then result := Result + Chr(Byte('A')+ul-10)

else result := Result + Chr(Byte('0')+ul);

End;

End;

1  COMMENTS
  • Profile
    신호성 2001.07.24 19:09
    64bit(8 Byte) integer 값은 16진수 문자열로 변환하는 함수 같군요.

    변수 u 는 integer값의 상위값부터 1Byte씩 추출한 값을 저장하는 변수

    (for 문이 상위부터 1Byte씩 추출하기 위해 7~0까지 반복되고 있음)

    변수 uh는 추출된 1Byte값인 u에서 다시 상위 4bit값을 가지고

    변수 ul은 하위 4bit값을 추출하여 각각(uh, ul)을 16진수 문자열로 변환합니다.











    정종섭 wrote:

    > 소스분석좀 해주세요..

    > integer형(32bit)을 64bit hex값으로 변환하는것 같은데..

    > u,uh,ul의 사용에대해 모르겠습니다.

    > 고수님들의 말씀 기다리겠습니다. ^.^*

    >

    > Function Int642Hex(nFmt: Int64): String;

    > var

    > z: Integer;

    > u, uh, ul: Byte;

    > Begin

    > result := '';

    > for z := 7 downto 0 do Begin

    > u := (nFmt shr (z * 8)) and $FF;

    > uh := (u shr 4) and $F;

    > ul := u and $F;

    > if uh >= 10 Then result := Result + Chr(Byte('A')+uh-10)

    > else result := Result + Chr(Byte('0')+uh);

    > if ul >= 10 Then result := Result + Chr(Byte('A')+ul-10)

    > else result := Result + Chr(Byte('0')+ul);

    > End;

    > End;