From owner-freebsd-questions@FreeBSD.ORG Tue Mar 7 15:22:28 2006 Return-Path: X-Original-To: freebsd-questions@freebsd.org Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 00AD916A420 for ; Tue, 7 Mar 2006 15:22:28 +0000 (GMT) (envelope-from freebsd-questions-local@be-well.ilk.org) Received: from mail4.sea5.speakeasy.net (mail4.sea5.speakeasy.net [69.17.117.6]) by mx1.FreeBSD.org (Postfix) with ESMTP id E54CA43D45 for ; Tue, 7 Mar 2006 15:22:25 +0000 (GMT) (envelope-from freebsd-questions-local@be-well.ilk.org) Received: (qmail 9128 invoked from network); 7 Mar 2006 15:22:25 -0000 Received: from dsl092-078-145.bos1.dsl.speakeasy.net (HELO be-well.ilk.org) ([66.92.78.145]) (envelope-sender ) by mail4.sea5.speakeasy.net (qmail-ldap-1.03) with SMTP for ; 7 Mar 2006 15:22:24 -0000 Received: by be-well.ilk.org (Postfix, from userid 1147) id 879AD28421; Tue, 7 Mar 2006 10:22:24 -0500 (EST) Sender: lowell@be-well.ilk.org To: kamal kc References: <20060306120257.61959.qmail@web30012.mail.mud.yahoo.com> From: Lowell Gilbert Date: 07 Mar 2006 10:22:24 -0500 In-Reply-To: <20060306120257.61959.qmail@web30012.mail.mud.yahoo.com> Message-ID: <44pskyi8jz.fsf@be-well.ilk.org> Lines: 40 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: freebsd-questions@freebsd.org Subject: Re: range of 32 bit unsigned int/long X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 07 Mar 2006 15:22:28 -0000 kamal kc writes: > the 16 bit unsigned integer takes the value as i checked myself > for 0 to 2^16-1 (=65535). > > but the 32 bit unsigned integer/long does not take the > value from 0 to 2^32-1 (4294967295). > instead 32 bit unsigned int/long takes the value from > 0 to 2^31-1 (2147483647). No, it takes on the full range you expected. [Depending on your hardware platform, of course.] Use UINT_MAX and see what values it takes. > the gcc shows that the message > warning: this decimal constant is unsigned only in ISO C90 > > what is happening, i am confused. It is telling you exactly what is happening. If you don't specify that a constant is unsigned, the latest version of the C Standard specifies that it is treated as int, long int, or long long int (the first one of that list which it will fit in). Take the following code as an example and look for a really good reference on the C language. #include int main(void) { unsigned int u = UINT_MAX; unsigned int m = 4294967295U; printf("UINT_MAX is %u\n",u); printf("m is %u\n",m); return 0; } You also might be interested in the comp.lang.c FAQ. http://www.eskimo.com/~scs/C-faq/faq.html