signed vs unsigned comparison warnings

Marc Espie espie@quatramaran.ens.fr
Tue Jun 20 13:21:00 GMT 2000


On Tue, Jun 20, 2000 at 09:14:28PM +0100, Joern Rennecke wrote:
> > In my experience, using unsigned in C is almost always a mistake.
> > The way conversion works, it does create all sorts of nasty problems
> > that don't exist with signed arithmetic, and the extra bit of precision
> > is VERY rarely useful.
> 
> Using unsigned instead of signed division by a constant power of two can
> make a significant difference in code size and speed.

If you are sure the value is positive, you can use shifts instead of
division, or am I missing something ?

You don't have to declare the variable unsigned and suffer from all the
nasty trouble this entails.


More information about the Gcc mailing list