Why unsigned chars not default?
Gordon Cross
crossgl at ingr.UUCP
Tue Oct 25 07:42:30 AEST 1988
In article <9563 at pur-ee.UUCP>, mendozag at pur-ee.UUCP (Grado) writes:
>
> However, much to his dismay, other compilers (LSC, MSC, and Unix)
> require him to declare as unsigned char the I/O buffer (which he
> also uses for arithmetic operations) else the chars are negative
> numbers when the their contents represents value > 127. (He does
> a lot of arithmetic with characters representing integers).
>
The proposed ANSI C standard states (I am quoting directly from the document):
" An object declared as a character (char) is large enough to store any
member of the required source charcater set [ .. ]. If such a character is
stored in a char object, its value is guaranteed to be non-negative. If other
quantities are stored in a char object, the behavior is implementation
defined: the values are treated as either signed or non-negative integers."
Basically, this allows each complier writer to explore his whims. Hope it
helps!
Gordon Cross
More information about the Comp.lang.c
mailing list