Mas opciones:
Código:
function BinaryStr(B: Byte): String;
var
I: Integer;
begin
SetLength(Result,8);
for I := 1 to 8 do begin
Result[i]:= PChar('01')[(B SHR (8-I)) AND 1];
end{for};
end;
Pero sin duda esta es la mas rapida de todas las opciones propuestas:
Código:
function BinaryStr(B: Byte): String;
var
I : Integer;
Ptr: PChar;
begin
SetLength(Result,8);
Ptr:= PChar(Result);
for I:= 7 downto 0 do begin
Ptr^:= PChar('01')[(B SHR I) AND 1];
Inc(Ptr);
end{for};
end;:
Saludos