Delphi-PRAXiS
Seite 2 von 2     12   

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Sonstige Fragen zu Delphi (https://www.delphipraxis.net/19-sonstige-fragen-zu-delphi/)
-   -   Delphi Dual Dezimal (https://www.delphipraxis.net/99597-dual-dezimal.html)

Reinhardtinho 14. Sep 2007 14:44

Re: Dual Dezimal
 
<Binärwert> ist hier doch nur ein Platzhalter, du musst natürlich den richtigen Binärwert als String übergeben.
ZB.'101010101010'.

MasterTobi 14. Sep 2007 14:52

Re: Dual Dezimal
 
meinst du das so
Delphi-Quellcode:
 var s:string;
begin
s:=inttostr (BinToDec (int64));

Reinhardtinho 14. Sep 2007 14:55

Re: Dual Dezimal
 
Eigentlich so:

Delphi-Quellcode:
var s:string;
begin
  s := IntToStr(BinToDec ('101010101010'));
end;

MasterTobi 14. Sep 2007 14:59

Re: Dual Dezimal
 
aso ja das hab ich auch schon probiert des geht ja.

ich hab grad nochma geschaut ich hab mich glaub net richtig ausgedrückt

also ich will in edit2.text eine dual zahl eingeben
un in edit1.text soll die dezi zahl stehen


Delphi-Quellcode:
function BinToDec(s:string):int64;
var p:int64;
    i:integer;
begin
p:=0;
for i:=1 to length(s) do
   p:=p*2+ord(s[i])-ord('0');//s[i] must be '0' or '1'
result:=p;
end;
procedure TForm2.Button2Click(Sender: TObject);
begin
edit1.Text := IntToStr( BinToDec (<binärcode>));
 end;
end.
anstatt <binärcode> muss ich ja irgendwie das result aus der function nehmen oder?

Die Muhkuh 14. Sep 2007 15:00

Re: Dual Dezimal
 
Delphi-Quellcode:
function BinToDec(s:string):int64;
var p:int64;
    i:integer;
begin
p:=0;
for i:=1 to length(s) do
   p:=p*2+ord(s[i])-ord('0');//s[i] must be '0' or '1'
result:=p;
end;
procedure TForm2.Button2Click(Sender: TObject);
begin
edit1.Text := IntToStr( BinToDec (Edit2.Text));
end;
end.

MasterTobi 14. Sep 2007 15:02

Re: Dual Dezimal
 
boah bin ich blöd :wall: :wall: :wall: :wall: :wall: :wall: :wall:

Thx @ all

mkinzler 14. Sep 2007 15:09

Re: Dual Dezimal
 
Zitat:

anstatt <binärcode> muss ich ja irgendwie das result aus der function nehmen oder?
Nein den Inhalt des Edits
Delphi-Quellcode:
Edit1.Text := IntToStr( BinToDec( edit2.text ));


Alle Zeitangaben in WEZ +1. Es ist jetzt 20:26 Uhr.
Seite 2 von 2     12   

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz