The internal representation of int
and unsigned int
is the same.
Therefore, when you pass the same format string to printf
it will be printed as the same.
However, there are differences when you compare them. Consider:
int x = 0x7FFFFFFF;
int y = 0xFFFFFFFF;
x < y // false
x > y // true
(unsigned int) x < (unsigned int y) // true
(unsigned int) x > (unsigned int y) // false
This can be also a caveat, because when comparing signed and unsigned integer one of them will be implicitly casted to match the types.