🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #3912

Re: Type of expression

#3912
From: Chris Torek
Date: Sun, 03 Sep 1995 23:50
28 lines
1591 bytes
In article <42dbat$qlq$1@mhade.production.compuserve.com>
Edward Diener  <70304.2632@CompuServe.COM> asks:
>Is the type of this constant, 0x80000000L, long int or unsigned 
>long int ?

Yes, that is exactly correct: it is long int or unsigned long int.

X3.159-1989, section 3.1.3.2, Integer Constants, p. 28, ll. 37--41:

	The type of an integer constant is the first of the
	corresponding list in which its value can be
	represented. ... suffixed by the letter |l| or |L|:
	|long int|, |unsigned long int|; ...

Thus, if 0x80000000 (2147483648) can be represented correctly as
a long int---e.g., on a 64-bit machine where 0x80000000 is really
0x0000000080000000---its type is `long int', otherwise its type
is `unsigned long int'.

If the number should have the type `unsigned long int', it can be
written as 0x80000000UL, 0x80000000LU, 0x80000000uL, etc.  A cast
in front of the constant will also serve (and will port to pre-ANSI
compilers).
-- 
In-Real-Life: Chris Torek, Berkeley Software Design Inc
Berkeley, CA	Domain:	torek@bsdi.com	+1 510 549 1145
  `... if we wish to count lines of code, we should not regard them as
   ``lines produced'' but as ``lines spent.'' '  --Edsger Dijkstra
Technical Details
Message-ID: <42df0h$73v@elf.bsdi.com>
Path: arc1-ca.pugleaf.net!cs.umd.edu!not-for-mail
References: <42dbat$qlq$1@mhade.production.compuserve.com>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!cs.umd.edu!not-for-mail
From: torek@elf.bsdi.com (Chris Torek)
Newsgroups: comp.std.c
Subject: Re: Type of expression
Date: 3 Sep 1995 16:50:41 -0700
Organization: Berkeley Software Design, Inc.
Message-ID: <42df0h$73v@elf.bsdi.com>
References: <42dbat$qlq$1@mhade.production.compuserve.com>
Reply-To: torek@bsdi.com
NNTP-Posting-Host: elf.bsdi.com