Delphi Tips&Tricks News   Tips   .NET Software   VCL Software   Search   Contacts
Ultimate Pack Special Offer!


Share this page

Follow us
LinkedIn Blogspot Twitter Facebook

Related products
Ultimate Pack  hot!
iGrid Plotter  new!
Image Editor
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
Print Suite .NET
Gradient Controls .NET  new!

Related links
Win32.hlp online version
MegaDetailed.NET
Delphi to C#

Special
Free Software Promotion
Offers for Resellers

Hobby projects
cdtrrracks.com
books.storrre.com
in3steps.com
sovietphillumeny.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