🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #3028

Re: Is INT_MAX<<1 defined?

#3028
From: Natuerlich!
Date: Tue, 15 Dec 1992 14:21
26 lines
1727 bytes
Just to raise the voice of one practicing programmer, who doesn't have the
standard at hand. What I expect to happen in expressions like these

	INT_MAX << 1

is that the compiler behaves as if it were ultralame. It acts as if it doesn't
precompute at compiletime but rather computes the result at runtime. So that 
in fact the default type for INT_MAX is signed int (since there isn't an U 
or an L anywhere) and the shifting operation operates on a signed int on that
system. For a 68000 I'd expect something that produces the same result
as this (lame) code:

	MOVE.L	#INTMAX,d0
	ASL.L	#1,d0

Obviously this may be non-portable, but so what ? If you want portability
you write  (long) INT_MAX * 2 (or somesuch).

To me any other interpretation (even if in the standard) obscures the 
C language. If you want to get a long out of INT_MAX << 1 then cast it.

Nat!
-- 
 -----   Email: wallmann@backus.pu.informatik.th-darmstadt.de  -----
               "Bang that bit that doesn't bang"   
                  VfL Bochum:  "Unabsteigbar"
Technical Details
Message-ID: <1992Dec15.142103.49328@news.th-darmstadt.de>
Path: arc1-ca.pugleaf.net!sparky!uunet!europa.asd.contel.com!howland.reston.ans.net!usc!cs.utexas.edu!qt.cs.utexas.edu!yale.edu!ira.uka.de!math.fu-berlin.de!news.th-darmstadt.de!backus.pu.informatik.th-darmstadt.de!wallmann
References: <1992Dec8.1 <Bz35no.J6M@jrd.dec.com> <8322@charon.cwi.nl>

Show Full Headers
Complete Article Headers
Newsgroups: comp.std.c
Path: arc1-ca.pugleaf.net!sparky!uunet!europa.asd.contel.com!howland.reston.ans.net!usc!cs.utexas.edu!qt.cs.utexas.edu!yale.edu!ira.uka.de!math.fu-berlin.de!news.th-darmstadt.de!backus.pu.informatik.th-darmstadt.de!wallmann
From: wallmann@backus.pu.informatik.th-darmstadt.de (Natuerlich!)
Subject: Re: Is INT_MAX<<1 defined?
Sender: news@news.th-darmstadt.de (The News System)
Message-ID: <1992Dec15.142103.49328@news.th-darmstadt.de>
Date: Tue, 15 Dec 1992 14:21:03 GMT
References: <1992Dec8.1 <Bz35no.J6M@jrd.dec.com> <8322@charon.cwi.nl>
Nntp-Posting-Host: backus.pu.informatik.th-darmstadt.de
Organization: MSD software vault #9 @THD
Lines: 26