Why unsigned chars not default?

Stephen J. Friedl friedl at vsi.COM
Sat Oct 22 14:12:45 AEST 1988


In article <9563 at pur-ee.UUCP>, mendozag at pur-ee.UUCP (Grado) writes:
> 
>    He claims the compilers are at fault and that all the compilers
>  should have 'unsigned char' as default for characters so you
>  can do all sorts of arithmetic with them.
>  Any comments and/or suggestions I can pass along?

There are very good reasons for this.

The large (overwhelming?) use of char variables is for
characters, where sign is not an issue.  While most modern
architectures can handle all data types in both signed and
unsigned manners, older machines had a "natural" method for byte
handling with a substantial penalty for doing it "the other way".
Apparently it was felt that this penalty was too high for what
was seen as limited utility.

If a machine supports signed and unsigned byte operations, it
is up to the compiler writer to select which ever one she likes
the most.

The dpANS will allow the /signed/ keyword to do the obvious
thing to chars, but it is unwise to rely on anything other than
unsigned.

-- 
Steve Friedl    V-Systems, Inc.  +1 714 545 6442    3B2-kind-of-guy
friedl at vsi.com     {backbones}!vsi.com!friedl    attmail!vsi!friedl
---------Nancy Reagan on the Three Stooges: "Just say Moe"---------



More information about the Comp.lang.c mailing list