Delphi/CB
•  Greatis •  Security •  AppDatabase •  Utilities •  Visual Basic • .NET •  just4fun
Delphi / C++ Builder
Components, utilities and tips for Delphi and C++ Builder developers
Hot Offer
Save your money!
Featured
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

News Tips .NET Software VCL Software Partners  

Convert octal to binary
Use OctToBin function to convert number in octal format to binary format.

function OctToBin(OctStr: string): string;

  function DecToBinStr(N: Integer): string;
  var
    S: string;
    i: Integer;
  begin
    if N<>0 then
      for i:=1 to SizeOf(N)*8 do
      begin
        if N<0 then
          S:=S+'1'
        else
          S:=S+'0';
        N:=N shl 1;
      end
    else
      S:='0';
    Delete(S, 1, Pos('1', S)-1);
    case Length(S) mod 3 of
      1: S:='00'+S;
      2: S:='0'+S;
    end;
    Result:=S;
  end;

var
  i: Integer;
begin
  Result:='';
  for i:=1 to Length(OctStr) do
  begin
    if not (OctStr[i] in ['0','1','2','3','4','5','6','7']) then
    begin
      ShowMessage('This is not octal number');
      Result:='';
      Break;
    end
    else
      Result:=Result+DecToBinStr(StrToInt(OctStr[i]));
      while (Result[1]='0')and(Length(Result)>1) do
        Delete(Result, 1, 1);
  end;
end;

Related topics
Convert binary to octal
Convert binary to hexadecimal
Convert hexadecimal to binary
Convert octal to decimal
Convert decimals to binary
Convert decimals to hexadecimals
Convert hexadecimals to decimals
Convert binary to decimals

For more
Delphi Help

Download source


Our Partner
DevArchive.com
Recommended
just4fun
Useful Resources
Win32.hlp Online
Unix Manual Pages
MegaDetailed.NET
in3steps.com
Newsletters
Subscribe to our news!    Subscribe to our news!


Greatis Software Greatis | Security | AppDatabase | Utilities | Delphi/CB | Visual Basic | .NET | just4fun

Contacts | Add to Favorites | Recommend to a Friend | Privacy Policy | Copyright © 1998-2008 Greatis Software