At 01:22 21-04-08 +0200, =?UTF-8?B?Q2hyaXN0aWFuIELDtmhtZQ==?= wrote: >Hi all, > >Given a 1611 target device and the lines > >--->8--- > >#include <stdint.h> > >// ... > >int32_t a; >uint16_t b = 8; > >a = -(b * 2u); > >--->8--- > >at which point and why will the hardware multiplier be >used to evaluate the expression ? And if it is, which >value would a contain at the end of the statement?
That depends on the optimisation settings. I guess that with optimisation off, the expression is evaluated according to the mathematically correct order. With optimisation on, anything may happen (math rules will be obeyed). In this case (multiply by 2) the compiler will probably use a shift instead of the multiplier. Perhaps you could elaborate a bit more on why you want to know. Your question is too generic for a precise answer. Nico Coesel
