Forum : ST7/STM8
Original Post
Post Information | Post |
---|---|
December 6, 2010 - 4:23pm
|
Hi, What does STM8 compiler do if I assign an unsigned integer variable's value to a signed integer variable and if the unsigned variable's value is out of the boundaries of signed value? I couldn't find any information in the compiler manual. An example is below. unsigned int u16_variable1; ... if(s16_variable2 < 0) Thanks&Regards |
Hi Volkan,
Our Compiler is strictly ISO C compliant. This means that the "upward conversion" is applied whenever necessary (on binary and ternary operators). In your example, u16 is bitwise-copied into s16, which will lead to a "-1" value for s16.
Best Regards,