Ver Mensaje Individual
  #33  
Antiguo 13-09-2007
Avatar de marceloalegre
[marceloalegre] marceloalegre is offline
Miembro Premium
 
Registrado: abr 2005
Ubicación: Mar del Plata - Argentina
Posts: 448
Reputación: 20
marceloalegre Va por buen camino
Post

Cita:
Empezado por marcoszorrilla Ver Mensaje

Antes de que venga Seoane:

Código Delphi [-]
procedure TForm1.Button1Click(Sender: TObject);
var
n:LongInt;
begin
For n:=96 to 126 do
begin
Memo1.Lines.Add(IntToStr(n)+' = '+IntToBin(n,8));
end;
end;

function IntToBin(Value: LongInt;Size: Integer): String;
var
i: Integer;
begin
Result:='';
for i:=Size downto 0 do
begin
if Value and (1 shl i)<>0 then
Result:=Result+'1'
else
Result:=Result+'0';
end;
end;





Un Saludo.
Vamos a poner antes el intToBin asi le compila a todo el mundo, y de paso le hacemos un cambio para mejorarlo. (una linea de codigo menos jajajajaj)

Código Delphi [-]
function IntToBin ( value: LongInt; digits: integer ): string;
begin
    result := StringOfChar ( '0', digits ) ;
    while value > 0 do begin
      if ( value and 1 ) = 1 then
        result [ digits ] := '1';
      dec ( digits ) ;
      value := value shr 1;
    end;
end;
 
procedure TForm1.Button1Click(Sender: TObject);
var
n:LongInt;
begin
  For n:=96 to 126 do
  begin
  Memo1.Lines.Add(IntToStr(n)+' = '+IntToBin(n,8));
  end;
end;

Jajaja y si,,, hay que festejar con codigo sin sentido!. Saludos.
__________________
Saludos.

Marcelo D. Alegre
Responder Con Cita