|
델파이 코드지만, 빌더로 바꿔서 쓰세요.
function IntToOct(Value: Integer; Digits: Integer): string;
const
OctalDigit = '01234567';
var
ResultDigits, i: Integer;
begin
Result := '';
ResultDigits := 0;
repeat
Result := OctalDigit[(Value mod 8) + 1] + Result;
Inc(ResultDigits);
Value := Value div 8;
until Value = 0;
if ResultDigits < Digits then
for i := ResultDigits + 1 to Digits do
Result := '0' + Result;
end;
function OctToInt(Value: string): Longint;
var
i: Integer;
int: Integer;
begin
int := 0;
for i := 1 to Length(Value) do
begin
int := int * 8 + StrToInt(Copy(Value, i, 1));
end;
Result := int;
end;
왕초보 님이 쓰신 글 :
: 에디트 박스에 10진수를 8진수값으로 바꿔서 출력하려고 합니다.
: 어떻게 하나요?
:
: 또 16진수값으로 바꾸는건 IntToHex()이던데 이것도 에러가 나더군요..
|