Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: utzoo!utgpu!water!watmath!clyde!bellcore!faline!scherzo!allegra!alice!ark
From: ark@alice.UUCP
Newsgroups: comp.lang.c,comp.sys.ibm.pc
Subject: Re: What's Wrong here?
Message-ID: <7490@alice.UUCP>
Date: Sun, 29-Nov-87 01:05:46 EST
Article-I.D.: alice.7490
Posted: Sun Nov 29 01:05:46 1987
Date-Received: Tue, 1-Dec-87 07:23:20 EST
References: <278@westmark.UUCP>
Organization: AT&T Bell Laboratories, Liberty Corner NJ
Lines: 23
Xref: utgpu comp.lang.c:5339 comp.sys.ibm.pc:9084

In article <278@westmark.UUCP>, dave@westmark.UUCP writes:
> Perhaps a C guru on the net can tell me what's wrong with this
> trivial C program?
> 
> #include 
> main()
> {
> 	long n;
> 	n = (1 << 31) -1;
> 	printf("%ld\n", n);
> }

The value of the expression

	1 << 31

is undefined on implementations where an int is less than 32 bits long.

If you wish to evaluate 1<<31 as a long, you must write

	n = (1L << 31) -1;

or some variation thereof.