Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!sdd.hp.com!spool.mu.edu!uunet!unisoft!greywolf From: greywolf@unisoft.UUCP (The Grey Wolf) Newsgroups: comp.lang.c Subject: Re: The use of unsigned int Keywords: unsigned int, C Message-ID: <3378@unisoft.UUCP> Date: 14 Feb 91 00:55:18 GMT References: <1255@tredysvr.Tredydev.Unisys.COM> Reply-To: greywolf@unisoft.UUCP (The Grey Wolf) Organization: Foo Bar and Grill Lines: 21 In article <1255@tredysvr.Tredydev.Unisys.COM> paul@tredysvr.Tredydev.Unisys.COM (Paul Siu) writes: >The most commonly use, and commonly returned type in C is probably int. >In some cases, wouldn't it be more appropriate if unsigned int was used >instead, such as when you are indexing an array, or returning a length? I've had occasion to use a signed int as an array index before; I don't think it's that uncommon. Unsigned ints are warranted in certain places, but int seems to be more versatile (you don't have to muck about with whichever value a failed system call returns). Also, as has been pointed out, the difference between signed and unsigned int on a two's-complement machine (most are these days) is purely semantic. >Paul Siu >paul@tredysvr.tredydev.unisys.com -- thought: I ain't so damb dumn! | Your brand new kernel just dump core on you war: Invalid argument | And fsck can't find root inode 2 | Don't worry -- be happy... ...!{ucbvax,acad,uunet,amdahl,pyramid}!unisoft!greywolf