Ver Mensaje Individual
  #1  
Antiguo 18-11-2014
elmago00 elmago00 is offline
Miembro
NULL
 
Registrado: ago 2013
Posts: 86
Reputación: 11
elmago00 Va por buen camino
¿Cómo convertir un integer a hexadecimal?

Hola que tal,
e estado intentado convertir un integer a un hexadecimal, que de como resultado:

Código:
[size - 16]

08 2A 65 13 42 65 98 22 45 00 00 00 00 00 00 00 // por que no corresponde el valor integer al este hexa
El valor integer que utilizo es 256312456892254

por ejemplo si yo convierto string a HEX:

Código Delphi [-]
function StringToHex(S: String): string;
var I: Integer;
begin
  Result:= '';
  for I := 1 to length (S) do
    Result:= Result+IntToHex(ord(S[i]),2);
end;

function HexToString(H: String): String;
var I: Integer;
begin
  Result:= '';
  for I := 1 to length (H) div 2 do
    Result:= Result+Char(StrToInt('$'+Copy(H,(I-1)*2+1,2)));
end;

y luego trato de pasar hex a string me genera un un hexa diferente.
utilizo el siguiente archivo.

UBigIntsV3.rar

Código Delphi [-]
function StrHexaToUInt64Str(const stringHexadecimal: String): string;
var
  unBigInteger:TInteger;
begin
  unBigInteger:=TInteger.Create;
  try
    // stringHexadecimal parameter is passed without the '$' symbol
    // ex: stringHexadecimal:='FFAA0256' and not '$FFAA0256'
    unBigInteger.AssignHex(stringHexadecimal);
    //the boolean value determine if we want to add the thousand separator or not.
    Result:=unBigInteger.converttoDecimalString(false);
  finally
    unBigInteger.free;
  end;
end;

Como hago para generar el mismo hexadecimal. lo que trato de hacer encontrar una función que genere lo mismo.
yo desconozco que función utilicen para generar ese raro valor hexadecimal con integer de 15


gracias por su respuesta

Última edición por elmago00 fecha: 18-11-2014 a las 21:32:25.
Responder Con Cita