Mega Code Archive

 
Categories / Delphi / Algorithm Math
 

How to convert an Integer to an octal number

Title: How to convert an Integer to an octal number function IntToOct(Value: Longint; digits: Integer): string; var rest: Longint; oct: string; i: Integer; begin oct := ''; while Value 0 do begin rest := Value mod 8; Value := Value div 8; oct := IntToStr(rest) + oct; end; for i := Length(oct) + 1 to digits do oct := '0' + oct; Result := oct; end;