Path: utzoo!attcan!uunet!pilchuck!dataio!fnx!nazgul!bright From: bright@nazgul.UUCP (Walter Bright) Newsgroups: comp.lang.c Subject: Re: The use of unsigned int Keywords: unsigned int, C Message-ID: <269@nazgul.UUCP> Date: 25 Feb 91 18:16:59 GMT References: <1255@tredysvr.Tredydev.Unisys.COM> <3378@unisoft.UUCP> Reply-To: bright@nazgul.UUCP (Walter Bright) Organization: Zortech, Seattle Lines: 11 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? If the values for your variables are never negative, you should declare them as unsigned. The reasons are: 1. Documentation 2. Aid to the optimizer. Certain optimizations are not possible if the variable could be negative, such as replacing a divide with a shift and replacing a loop index with a pointer.