home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / std / c / 3213 < prev    next >
Encoding:
Text File  |  1992-12-15  |  1.6 KB  |  39 lines

  1. Newsgroups: comp.std.c
  2. Path: 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
  3. From: wallmann@backus.pu.informatik.th-darmstadt.de (Natuerlich!)
  4. Subject: Re: Is INT_MAX<<1 defined?
  5. Sender: news@news.th-darmstadt.de (The News System)
  6. Message-ID: <1992Dec15.142103.49328@news.th-darmstadt.de>
  7. Date: Tue, 15 Dec 1992 14:21:03 GMT
  8. References: <1992Dec8.1 <Bz35no.J6M@jrd.dec.com> <8322@charon.cwi.nl>
  9. Nntp-Posting-Host: backus.pu.informatik.th-darmstadt.de
  10. Organization: MSD software vault #9 @THD
  11. Lines: 26
  12.  
  13. Just to raise the voice of one practicing programmer, who doesn't have the
  14. standard at hand. What I expect to happen in expressions like these
  15.  
  16.     INT_MAX << 1
  17.  
  18. is that the compiler behaves as if it were ultralame. It acts as if it doesn't
  19. precompute at compiletime but rather computes the result at runtime. So that 
  20. in fact the default type for INT_MAX is signed int (since there isn't an U 
  21. or an L anywhere) and the shifting operation operates on a signed int on that
  22. system. For a 68000 I'd expect something that produces the same result
  23. as this (lame) code:
  24.  
  25.     MOVE.L    #INTMAX,d0
  26.     ASL.L    #1,d0
  27.  
  28. Obviously this may be non-portable, but so what ? If you want portability
  29. you write  (long) INT_MAX * 2 (or somesuch).
  30.  
  31. To me any other interpretation (even if in the standard) obscures the 
  32. C language. If you want to get a long out of INT_MAX << 1 then cast it.
  33.  
  34. Nat!
  35. -- 
  36.  -----   Email: wallmann@backus.pu.informatik.th-darmstadt.de  -----
  37.                "Bang that bit that doesn't bang"   
  38.                   VfL Bochum:  "Unabsteigbar"
  39.