[Home]  [Edit this page]  [Recent Changes]  [Special Pages]  [Help
BinToInt
Author : DJ_Sannie
E-Mail : DJ_Sannie@yahoo.com
Date : March 30, 2004






function BinToInt( Binary: String ):Integer;
var
  i, j: Integer;
begin
  Result := 0;
  j := 1;
  for i := Length( Binary ) downTo 1 do
  begin
    Result := Result + StrToInt( Binary[i] ) * j;
    j := j*2;
  end;
end;
function BinToInt(Bin: array of boolean): cardinal; overload;
var
  i: integer;
  BinStr: string;
begin
  BinStr := '';
  for i := 0 to High(Bin) do
    if Bin[i] then
      BinStr := '1'+BinStr
    else
      BinStr := '0'+BinStr;
  Result := BinToInt(BinStr);
end;
function BinToInt64(Bin: array of boolean): Int64; overload;
var
  i: integer;
  BinStr: string;
begin
  BinStr := '';
  for i := 0 to High(Bin) do
    if Bin[i] then
      BinStr := '1'+BinStr
    else
      BinStr := '0'+BinStr;
  Result := BinToInt64(BinStr);
end;
function BinToInt64(Bin: string): Int64; overload;
var
  i: integer;
  j: Int64;
begin
  Result := 0;
  j := 1;
  for i := Length(Bin) downto 1 do
  begin
    if Bin[i] = '1' then
      Result := Result + j;
    j := j * 2;
  end;
end;


last edited (April 4, 2004) by zibadian, Number of views: 2277, Current Rev: 2 (Diff)

[Edit this page]  [Page history]  [What links here]  [Discuss this topic]  [Printer Friendly]  

Members

Username:

Password:


Register
Forgot Password?




Programmers Heaven - for .NET, Java, C/C++ and WEB Developers!
© 1996-2008 Community Networks Ltd. All rights reserved. Reproduction in whole or in part, in any form or medium without express written permission is prohibited. Violators of this policy may be subject to legal action. Please read Terms Of Use and Privacy Statement for more information. Development by Tore Nestenius at .NET Consultant - Synchron Data.