[ Passwd @ 21.06.2005. 14:37 ] @
Evo, program koji obican broj pretvori u binarni....prilagodjen pascalu savrseno radi, al u delphi nece (vjerujem da je problem kod:for j:=i downto 1 do Edit4.Text:=binarni[j])...........

Code:

procedure TForm1.Button5Click(Sender: TObject);
var br:integer;
    i,ost,j:byte;
    binarni:string;
begin
br:=StrToInt(Edit3.Text);
i:=0;
ost:=0;
while br>0 do
begin
i:=i+1;
ost:=br mod 2;
if ost=0 then binarni:='0'
         else binarni:='1';
br:=br div 2;
for j:=i downto 1 do
begin
Edit4.Text:=binarni[j];
end;
end;
end;


[ bondja @ 21.06.2005. 15:02 ] @
Code:

var br:integer;
    i,ost,j:byte;
    binarni:string;
begin
  br:=StrToInt(Edit3.Text);
  i:=0;
  ost:=0;
  while br>0 do
  begin
    i:=i+1;
    ost:=br mod 2;
    if ost=0 then binarni := '0' + binarni
             else binarni := '1' + binarni;
    br:=br div 2;
  end;

  Edit4.Text := binarni;
end;

Pozdrav!
[ Passwd @ 21.06.2005. 15:15 ] @
E sad radi
Ajde mi sad jos samo objasni zasto je to trebalo napravit ??
[ Passwd @ 21.06.2005. 15:53 ] @
A kako bi izgledao kod za pretvaranje obicnog u heksadekatski.....ali opet ne radi


Code:

procedure TForm1.Button6Click(Sender: TObject);
var broj:longint;
    ost,i,j:byte;
    heksa:string;
begin
broj:=StrToInt(Edit5.Text);
i:=0;
while broj>0 do
begin
i:=i+1;
ost:=broj mod 16;

if ost=1 then heksa:='1'+heksa;
if ost=2 then heksa:='2'+heksa;
if ost=3 then heksa:='3'+heksa;
if ost=4 then heksa:='4'+heksa;
if ost=5 then heksa:='5'+heksa;
if ost=6 then heksa:='6'+heksa;
if ost=7 then heksa:='7'+heksa;
if ost=8 then heksa:='8'+heksa;
if ost=9 then heksa:='9'+heksa;
if ost=10 then heksa:='A'+heksa;
if ost=11 then heksa:='B'+heksa;
if ost=12 then heksa:='C'+heksa;
if ost=13 then heksa:='D'+heksa;
if ost=14 then heksa:='E'+heksa;
if ost=15 then heksa:='F'+heksa;

end;

broj:=broj div 16;
Edit6.Text:=heksa;
end;
[ Toyo @ 21.06.2005. 16:00 ] @
Ubaci broj := broj div 16 u petlju (iznad end;)
[ Srki_82 @ 21.06.2005. 16:13 ] @
Zasto ne probas IntToHex funkciju!?
[ Passwd @ 21.06.2005. 17:42 ] @
Zato jer nisam cuo za nju