Delphi Tips&Tricks News   Tips   .NET Software   VCL Software   Search   Contacts
Ultimate Pack - special offer!

Ultimate Pack  hot!
Image Editor  new!
Runtime Fusion
Form Designer
Object Inspector
Print Suite Pro
Commented Image
Delphi Toys
WinDowse
Delphi Bonus
TMS Scripter Studio
Form Designer VB
Form Designer .NET

...get more...
for Delphi.NET, C#, VB.NET
for Delphi VCL, BCB 3-6

WinAPI Online
Unix Manual Pages
MegaDetailed.NET
in3steps.com
cdtrrracks.com new!

Blogspot  greatis.blogspot.com

Convert octal to decimal - Mathematics - Tips & Tricks - Greatis Delphi Pages

Use function OctToDec to convert number in octal format to decimat format. It is not very difficult, because 217 in octal is 2*8*8+1*8+7 in decimal format.


function OctToDec(OctStr: string): string;
var
  DecNum: Real;
  i: Integer;
  Error: Boolean;
begin
  DecNum:=0;
  Error:=False;
  for i:=Length(OctStr) downto 1 do
  begin
    if not (OctStr[i] in ['0','1','2','3','4','5','6','7']) then
    begin
      Error:=True;
      ShowMessage('This is not octal number');
      Break;
    end;
    DecNum:=DecNum+StrToInt(OctStr[i])*Power(8, Length(OctStr)-i);
  end;
  if not Error then
    Result:=FloatToStr(DecNum)
  else Result:='';
end;
Related topics
Convert binary to octal
Convert octal to binary
Convert hexadecimal to binary
Convert binary to hexadecimal
Convert decimals to binary
Convert decimals to hexadecimals
Convert hexadecimals to decimals
Convert binary to decimals

For more
Delphi Help

Download source