0

When dealing with signed int conversion to hex, only Integer.toString(value, 16) is useful

see a post on subject but I need to format with 4 hex digits (leading zeros for positive numbers and not 32bits/8chars for negatif numbers),

in C++ the right function is IntToHex( value,4) http://docwiki.embarcadero.com/Libraries/XE3/en/System.SysUtils.IntToHex

But I didn't fiund the equivalent in Java (Android).

Community
  • 1
  • 1
Lotfi
  • 660
  • 1
  • 6
  • 21

1 Answers1

0

Found it :

int StepRef =-2;
String SS = String.format("%08X",StepRef);
String SS4 = SS.substring(SS.length() - 4);
Lotfi
  • 660
  • 1
  • 6
  • 21