I have an 8-character string representing a hexadecimal number and I need to convert it to an int. This conversion has to preserve the bit pattern for
string
int
unsigned int u = ~0U; int s = *reinterpret_cast(&u); // -1
Сontrariwise:
int s = -1; unsigned int u = *reinterpret_cast(&s); // all ones