mirror of
https://github.com/doublecmd/doublecmd.git
synced 2026-06-28 10:02:14 +00:00
ADD: DecToOct function
This commit is contained in:
parent
c0c60b04f5
commit
f211dfa667
1 changed files with 19 additions and 0 deletions
19
udcutils.pas
19
udcutils.pas
|
|
@ -146,6 +146,12 @@ function StrNewW(const mbString: UTF8String): PWideChar;
|
|||
@returns(Decimal number)
|
||||
}
|
||||
function OctToDec(Value: String): LongInt;
|
||||
{en
|
||||
Convert a number specified as an decimal number to it's octal value.
|
||||
@param(Value Decimal number)
|
||||
@returns(Octal number as string)
|
||||
}
|
||||
function DecToOct(Value: LongInt): String;
|
||||
|
||||
implementation
|
||||
uses
|
||||
|
|
@ -565,5 +571,18 @@ begin
|
|||
Result:= Result * 8 + StrToInt(Copy(Value, I, 1));
|
||||
end;
|
||||
|
||||
function DecToOct(Value: LongInt): String;
|
||||
var
|
||||
iMod: Integer;
|
||||
begin
|
||||
while Value >= 8 do
|
||||
begin
|
||||
iMod:= Value mod 8;
|
||||
Value:= Value div 8;
|
||||
Result:= IntToStr(iMod) + Result;
|
||||
end;
|
||||
Result:= IntToStr(Value) + Result;
|
||||
end;
|
||||
|
||||
end.
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue