Code:
When u is 0, i should be -32768.
When u is 32768, i should be 0.
When u is 65535, i should be 32767.
Which of the following is correct:
i = (unsigned int) u or
i = (unsigned int) (u - 32768)?
As a matter of form, neither is correct, although the second is closest to your requirements. Assuming you have defined 'u' as unsigned int, and 'i' as int, you use:
i = (int) (u - 32768);