I'm looking for a fast way to convert uint32_t
to int32_t
. I can assume that all numbers are smaller than 2^31-1 and do not need to worry about overflow at this point in the code. Can I assume that the sign bit of an int32_t
is the largest digit of an uint32_t
? In terms of coding can I treat a pointer to a uint32_t
value as a pointer to an int32_t
value: Is the following code valid platform independent C code and will the last statement be true? (It is true on my Mac and with the intel compilers on linux)
uint32_t ui = 3;
int32_t *i = &ui;
(int32_t)ui == *i;