home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / std / c / 3215 < prev    next >
Encoding:
Internet Message Format  |  1992-12-16  |  1.4 KB

  1. From: boyne@hplvec.LVLD.HP.COM (Art Boyne)
  2. Date: Mon, 14 Dec 1992 20:09:41 GMT
  3. Subject: Re: Is INT_MAX<<1 defined?
  4. Message-ID: <71790001@hplvec.LVLD.HP.COM>
  5. Organization: Hewlett-Packard Co., Loveland, CO
  6. Path: sparky!uunet!cs.utexas.edu!qt.cs.utexas.edu!yale.edu!spool.mu.edu!sdd.hp.com!hpscit.sc.hp.com!hplextra!hpfcso!hplvec!boyne
  7. Newsgroups: comp.std.c
  8. References: <723345673snx@genesis.demon.co.uk>
  9. Lines: 20
  10.  
  11. In comp.std.c, dik@cwi.nl (Dik T. Winter) writes:
  12.  
  13. >   What it comes down to is that << is not a mathematical operation, there
  14. >   is nothing in mathematics that tells us that 16384 << 1 equals 32768.
  15. >   So what is the meaning of:
  16.  
  17. I'm not so sure about that.  Conceptually, the common-usage interpretation
  18. of the operation a << b can be represented mathematically as a*(2^b).
  19. I can even propose a hypothetical machine that lacks a true shift instruction
  20. and actually implements the << and >> operators by such means, especially
  21. when b is a constant.
  22.  
  23. Given that potential implementation, it is easy to imagine that INT_MAX << 1
  24. would generate overflow on such a machine.  Now, considering that the ANSI
  25. standard in general places as few restrictions as possible on implementations
  26. so as to maximize performance, I'm not sure that there is anything in the
  27. standard that would judge this implementation as non-conforming.
  28.  
  29. Art Boyne, boyne@hplvla.lvld.hp.com
  30. "An innocent bystander bemused by the furor of this discussion"
  31.