I'm looking for the exact rules according to standard of casting an integer type of signed type to an unsigned integer of the same rank, as well as the contrary (unsigned to signed).

ie:
signed char to unsigned char
unsigned int to signed int
etc...
but not signed char to unsigned int.

In particular, I want to know what happens on machines that do, or don't, use 2's complement. How they behave differently.

Is it safe to write:

Code:
unsigned int max_value = -1;
On any architecture?

The answers I found on the internet were too shady for my tastes.