Hola
Yo uso esta funcion:
De Hexa a Binario:
Código Delphi
[-]function HextoBin(Hexadecimal:string):string;
const
BCD: array [0..15] of string=
('0000','0001','0010','0011','0100','0101','0110','0111',
'1000','1001','1010','1011','1100','1101','1110','1111');
var
i:integer;
begin
for i:=Length(Hexadecimal) downto 1 do
Result:=BCD[StrToInt('$'+Hexadecimal[i])]+Result;
end;
ejemplo de llamada:
Código Delphi
[-]Label1.Caption:=HextoBin('FA');
De binario a hexa
Código Delphi
[-]function BinToHex(Binario:string):string;
const
BCD: array [0..15] of string=
('0000','0001','0010','0011','0100','0101','0110','0111',
'1000','1001','1010','1011','1100','1101','1110','1111');
HEX: array [0..15] of char=
('0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F');
var
i,n:integer;
sTemp:string;
sNibble:string;
begin
Result:='';
sTemp:=Binario+Copy('000',1,Length(Binario) mod 4);
for i:=0 to (Length(Binario) shr 2)-1 do
begin
sNibble:=Copy(sTemp,(i shl 2)+1,4);
n:=8;
while (sNibble <> BCD[n]) do
if sNibble < BCD[n] then Dec(n) else Inc(n);
Result:=Result+HEX[n];
end;
end;
Llamada
Código Delphi
[-]Label1.Caption:=BintoHex('100011100100101011');
Saludos
Augusto