Re: Advice on Unsigned Types

H. Peter Anvin (hpa@zytor.com)
4 Sep 2001 18:00:19 -0700


Followup to: <3B8EF269.BF457C7F@home.com>
By author: John Kacur <jkacur@home.com>
In newsgroup: linux.dev.kernel
>
> The advice the author give on Unsigned Types is:
> "Avoid unnecessary complexity by minimizing your use of unsigned types.
> Specifically, don't use an unsigned type to represent a quantity just
> because it will never be negative (e.g."age" or "national debt").
> Use a signed type like int and you won't have to worry about boundary
> cases in the detailed rules for promoting mixed types.
> Only use unsigned types for bitfields or binary masks. Use casts in
> expressions, to make all the operands signed or unsigned, so the
> compiler does not have to choose the result type."
>

So the author isn't talking about developing operating systems. In
operating systems it's almost the other way around -- signed is really
the exception.

-hpa

-- 
<hpa@transmeta.com> at work, <hpa@zytor.com> in private!
"Unix gives you enough rope to shoot yourself in the foot."
http://www.zytor.com/~hpa/puzzle.txt	<amsp@zytor.com>
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/