Autor Beitrag
maxk
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1696
Erhaltene Danke: 1

Win XP, Debian Lenny
Delphi 6 Personal
BeitragVerfasst: So 15.08.04 13:06 
Hi,
erstmal ein bisschen Code:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
type Str8=string[8];
var Buf: string;
    AS8: Str8;
    AI8: Int64;
    i:   integer;
begin
 for i:=Low(AS8) to High(AS8) do AS8[i]:=#0;
 AI8 := 1;

 Move(AI8,AS8,8);

 SetLength(Buf,16);
 for i:=1 to 8 do Buf[i]:=AS8[i];
 AI8:=0;

 Move(Buf,AI8,8);
 Caption:=IntToStr(AI8);
 Exit;
Leider steht in meinem Caption zum Schluss, keine 1 - Warum? Gibt's noch einen einfacheren Weg, Zahlen binär in einenen String zu legen. Ich hoffe, mir kann jemand helfen!

Gruß,
maxk

_________________
Ein Computer wird das tun, was Du programmierst - nicht das, was Du willst.
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: So 15.08.04 21:15 
Ganz einfach eigentlich:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
function IntToBinary(AInt:Int64): String;
var
    X: Integer;
begin
    Result := '';
    For X := 63 downto 0 do
        Result := Result + Chr(48 + 1 and (AInt shr X));
end;

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.
maxk Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1696
Erhaltene Danke: 1

Win XP, Debian Lenny
Delphi 6 Personal
BeitragVerfasst: Mo 16.08.04 13:47 
Habe gestern noch eine andere Lösung gefunden. Aber vergessen es hier zu posten :oops: Vorab, deine ist besser!
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
type Str8=string[8];  
var Buf: string;  
    AS8: Str8;  
    AI8: Int64;  
    i:   integer;  
begin  
 for i:=Low(AS8) to High(AS8) do AS8[i]:=#0;  
 AI8 := 1;  

 
 Move(AI8,AS8,8);  

 
 SetLength(Buf,16);  
 for i:=1 to 8 do Buf[i]:=AS8[i];  
 AI8:=0;  

 for i:=1 to 8 do AS8[i]:=Buf[i];  // <= Anders

 Move(AS8,AI8,8);   // <= Anders
 Caption:=IntToStr(AI8);  
 Exit;

Mir ist nur nicht klar, warum das so ist? Kann mir das jemand erklären?

_________________
Ein Computer wird das tun, was Du programmierst - nicht das, was Du willst.