The following lines of code output "FFFFFFFF"
This is the 32-bit representation of -1 in Hex. I'm trying to get it to output fewer bits: e.g. 24-bit: FFFFFF In fact, the output I want needs to be 6 digits in all cases. So, if I replaced i=-1 with i=1 I need the output to be 000001. I can do this by padding with 0's
(i.e., use printf("\n%06X\n",i);)
but the negative case still outputs FFFFFFFF. I vaguely understand why this is happening, but not sure the easiest way to fix. I could convert the output to a string, and chop off the first two characters, but this seems a bit convoluted. Any suggestions?