Path: utzoo!mnetor!uunet!yale!mfci!root From: root@mfci.UUCP (SuperUser) Newsgroups: comp.lang.c Subject: Re: unsigned comparsions Message-ID: <379@m3.mfci.UUCP> Date: 2 May 88 17:44:55 GMT References: <12578@brl-adm.ARPA> <1988Mar25.172355.348@utzoo.uucp> <375@m3.mfci.UUCP> <11304@mimsy.UUCP> Reply-To: karzes@mfci.UUCP (Tom Karzes) Organization: Multiflow Computer Inc., Branford Ct. 06405 Lines: 15 Summary: Expires: Followup-To: Distribution: Keywords: In article <11304@mimsy.UUCP> chris@mimsy.UUCP (Chris Torek) writes: >[They were equivalent. The comparison was |unsigned char| != -1, which >---provided |char| is shorter than |int|---is indeed always true, in both >the existing sign preserving system and in the value preserving system in >the dpANS.] Oops, I hadn't noticed that the routine was returning an unsigned char, I only noticed the unsigned. Yes, assuming chars are shorter than ints then an unsigned char, when zero-padded out to a full int, will never have the same bit pattern as -1. (I should add that I've always thought that C routines which return chars or shorts should be avoided, and that such data types should only be used for arrays and structure members, since C prefers to deal with full size integers, and using chars and shorts will at best cost you a bunch of useless sign extensions/zero fills and truncations, and at worst will cause unexpected results.)