Link to home
Create AccountLog in
Avatar of lacroix_al
lacroix_al

asked on

Long integer to Hex

Hi,
I am having some trouble converting a long integer to hex.
I have tryied using the toHex(long n).
Is this the proper way to do this or is there a better way?
Al
ASKER CERTIFIED SOLUTION
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Integer.toHexString(myLong);
(Of course that needs assignment)

String s =  Long.toString(n, 16);
try this

String strHexa = Long.toHexString(myLong);
Avatar of lacroix_al
lacroix_al

ASKER

Thanks
Al
>> I have tryied using the toHex(long n).

You mean Long.toHex ( long n ) ? That is already perfectly correct.
>> Long.toHex ( long n )

Long.toHexString ( long n )
:-)
yes

String str =  Long.toString(num, 16);

or

String str = Long.toHexString(num);

will solve your problem.