Cita:
Empezado por marcoszorrilla
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.