masmic masmic - 1 month ago 4
Android Question

android int to hex converting

I have to convert an int to an hex value. This is for example the int value:

int_value = -13516;

To convert to a hex value i do:

hex_value = Integer.toHexString(int_value);

The value that I should get is :
(I don't know if i should make it positive).

The thing is that doing the conversion that way, the value that I get is:
ffff cb34

Can't I use this function to make this conversion?


Documentation says Integer.toHexString returns the hexadecimal representation of the int as an unsigned value.

I believe Integer.toString(value, 16) will accomplish what you want.