This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

C51 750 compile bug!

volatile unsigned int Wi;

Wi= (0x4000*3)/(0x10);

//The compliler will make Wi = 0xfc00 !!
//The right answere is Wi = 0x0c00!!

Parents
  • A constand of 0xb000, however, is unsigned in 16-bit ANSI C compilers. Getting this right might require the "apply ANSI integer promotions" switch of C51 to be active.

    Refer to 6.3.1.8 Usual arithmetic conversions in the ANSI spec for what's actually happening in the case mentioned. In this situation, the result being a signed int is correct.

    Jon

Reply
  • A constand of 0xb000, however, is unsigned in 16-bit ANSI C compilers. Getting this right might require the "apply ANSI integer promotions" switch of C51 to be active.

    Refer to 6.3.1.8 Usual arithmetic conversions in the ANSI spec for what's actually happening in the case mentioned. In this situation, the result being a signed int is correct.

    Jon

Children