Thema: Delphi Bin in Dec umwandeln

Einzelnen Beitrag anzeigen

Benutzerbild von Duffy
Duffy

Registriert seit: 19. Mär 2003
Ort: Wuppertal
835 Beiträge
 
Delphi 3 Standard
 
#3
  Alt 3. Apr 2003, 18:10
Hallo,
hier ist mal ein Lösungsansatz. Viel Spaß

bye

Delphi-Quellcode:
function NumBin(B: string): Longint;
var
  Accum, Power: Longint;
  P: Byte;
begin
  Power := 1;
  Accum := 0;
  for P := Length(B) downto 1 do
  begin
    If (B[P] = '0') or (B[P] = '1') then
    begin
      If B[P] = '1then
      begin
        Inc(Accum, Power);
      end;
      Power := Power shl 1;
    end;
  end;
  NumBin := Accum;
end;
  Mit Zitat antworten Zitat