Autor Beitrag
foxy
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 814

Ubuntu, Gentoo
C++, PHP, Java, Ruby, Perl (Eclipse)
BeitragVerfasst: Mo 15.09.03 13:30 
sers ... also ich hab mir gerade mal gedanken da nomma gemacht is schon ein bissal her

ich weis den umrechnungsfaktor nimma ... bzw ich will das in einem algo machen

also am besten div oder ??

nur ich versteh die systematik nich wie weit ich das dann machen muss.

bsp:

eingabe 7 dann muss doch ka 000001 rauskomemn also ein binär wert nur wie komm ich eben auf den ??

_________________
"Only wimps use tape backup: real men just upload their important stuff on ftp, and let the rest of the world mirror it." (Linus Torvalds)
OperatingSystem Laptop (Ubuntu Hardy)
foxy Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 814

Ubuntu, Gentoo
C++, PHP, Java, Ruby, Perl (Eclipse)
BeitragVerfasst: Mo 15.09.03 13:49 
sry ich dumm


habs schon

_________________
"Only wimps use tape backup: real men just upload their important stuff on ftp, and let the rest of the world mirror it." (Linus Torvalds)
OperatingSystem Laptop (Ubuntu Hardy)
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: Mo 15.09.03 18:43 
ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
function IntToNumSys(Int,Basis:integer):string;
var E:integer;
begin
 if not (Basis in [1..9]) then begin
  raise Exception.Create('Basis must in [1..9]');
  exit;
 end;
 if Int<Basis then begin
  Result:=IntToStr(Int);
  exit;
 end;
 Result:='';
 E:=Int;
 while E>0 do begin
  Result:=IntToStr(E mod Basis)+Result;
  E:=E div Basis;
 end;
end;

function NumSysToIntDef(NumSys:string;Basis,Default:integer):integer;
var i,Ei,Exp:integer;
begin
 Result:=0;
 for i:=1 to length(NumSys) do begin
  if StrToIntDef(NumSys[i],Basis)>=Basis then begin
   Result:=Default;
   exit;
  end;
  if (length(NumSys)-i)=0 then Exp:=1 else begin
   Exp:=Basis;
   for Ei:=1 to length(NumSys)-i-1 do Exp:=Exp*Basis;
  end;
  Result:=Result+(StrToInt(NumSys[i])*Exp);
 end;
end;
Die Basis für Binär ist 2. Das Octansystem benutzt 8.

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