Path: utzoo!attcan!uunet!peregrine!ccicpg!cci632!rit!tropix!moscom!ur-valhalla!uhura.cc.rochester.edu!rochester!rutgers!jarvis.csri.toronto.edu!utgpu!watmath!watdragon!lion!jyegiguere From: jyegiguere@lion.waterloo.edu (Eric Giguere) Newsgroups: comp.lang.c Subject: Re: What's a C expert? Message-ID: <14559@watdragon.waterloo.edu> Date: 22 Jul 89 06:48:44 GMT References: <12214@well.UUCP> <6057@microsoft.UUCP> <4722@alvin.mcnc.org> <25999@amdcad.AMD.COM> <4724@alvin.mcnc.org> <1528@uw-entropy.ms.washington.edu> Sender: daemon@watdragon.waterloo.edu Reply-To: jyegiguere@lion.waterloo.edu (Eric Giguere) Organization: U. of Waterloo, Ontario Lines: 31 In article <25999@amdcad.AMD.COM> tim@amd.com (Tim Olson) writes: > Having the sign of chars be undefined allows the implementation to be as > efficient as possible with respect to converting between chars and ints. In article <4724@alvin.mcnc.org> spl@mcnc.org.UUCP (Steve Lamont) replies: > I > thought the standard was supposed to clarify things, not confuse the > issue. It's almost like saying that a declaration of int may be either > signed or unsigned. Makes for somewhat unpredictable behavior and/or > some fairly verbose defensive coding... As someone else pointed out, part of the "Spirit of C" is to be as efficient as possible without unduly constraining the users of the language... hence a 'char' can be signed or unsigned depending upon which fits a particular machine best... That said, the real reason why the pStandard does not specify that char should be signed or unsigned is that one of the overriding principles of the ANSI document is to not invalidate current programming practice.... the "new" C should be as upwardly-compatible as possible with the "old" C. Because many implementations had `char' as signed and many others had it as unsigned, the Committee chose to do nothing about the ambiguity. If you want a signed type and are using ANSI compilers, used 'signed char'. 'unsigned char' should work on all current C compilers.... but to get a signed char on some pre-ANSI machines you might actually have to fake it by going up to a short... Eric Giguere 268 Phillip St #CL-46 For the curious: it's French ("jee-gair") Waterloo, Ontario N2L 6G9 Bitnet : GIGUERE at WATCSG (519) 746-6565 Internet: giguere@aries5.UWaterloo.ca "Nothing but urges from HELL!!"