Hi,
I need to convert a number to a hexadecimal format. In my context, it is important that the output string has a defined length. I am facing issues when appyling the conversion to negative numbers. See the code below. As you can see, the length of output #2 and #3 is 8 instead of 4. Any hint would be appreciated.
Thanks, Adam
Code
var x1 = 18, x2 = -18;
System.println(x1.format("%04X"));
System.println(x2.format("%04X"));
System.println(x2.format("%+04X"));
Output
0012
FFFFFFEE
FFFFFFEE