Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
7 years, 8 months ago.
LPC1768: how to get a true 16-bit signed value?
Hey everyone, how do you get a real 16-bit signed value on this platform?
This code snippet:
int16_t test = -1; if (test == 0xFFFF) { printf("Success!\n"); } else { printf("No match.\n"); }
prints out No match, and only prints success if test == 0xFFFFFFFF.
How can this be changed for test == 0XFFFF to be true?
Thank you!
2 Answers
7 years, 8 months ago.
Hello Andrique,
That's strange. However the code below works as expected:
int16_t test = -1; int16_t ffff = 0xFFFF; printf("Size of test = %d\r\n", sizeof(test)); printf("Size of ffff = %d\r\n", sizeof(ffff)); if (test == ffff) { printf("Success!\r\n"); } else { printf("No match.\r\n"); }