How to change int to hex

Asked 2 years ago, Updated 2 years ago, 146 views

int_value = -13516; There's a value like this, but I want to change it to a hexadecimal value.

hex_value = Integer.toHexString(int_value);

I did it like above, but the value comes out ffffcb34

But what I want is -34CC. Did I do something wrong?

android hex int

2022-09-22 22:33

1 Answers

Looking up the document, Integer.toHexString returns the hexadecimal number of unsigned values. I think if you do Integer.toString(value,16), you'll get the result you want.


2022-09-22 22:33

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.