The use of unsigned int

The Grey Wolf greywolf at unisoft.UUCP
Thu Feb 14 11:55:18 AEST 1991


In article <1255 at tredysvr.Tredydev.Unisys.COM> paul at 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 at 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



More information about the Comp.lang.c mailing list