Re:Dangerous Embedded C Coding Standard Rules (2011)
by kps on Monday December 30, 2013 @12:45PM
(#6985718)
… which will (normally) only happen if the dividend is unsigned.
Another reason to prefer unsigned ints is that the C standards make signed overflow undefined. This is becoming increasingly important as code for embedded systems is built using ‘big’ optimizing compilers, rather than the simple ‘portable assemblers’ assumed by the old old rules of thumb like manually converting divides to shifts.
“If you lie to the compiler, it will get its revenge.” — Henry Spencer
Another reason to prefer unsigned ints is that the C standards make signed overflow undefined. This is becoming increasingly important as code for embedded systems is built using ‘big’ optimizing compilers, rather than the simple ‘portable assemblers’ assumed by the old old rules of thumb like manually converting divides to shifts.