home *** CD-ROM | disk | FTP | other *** search
- From: boyne@hplvec.LVLD.HP.COM (Art Boyne)
- Date: Mon, 14 Dec 1992 20:09:41 GMT
- Subject: Re: Is INT_MAX<<1 defined?
- Message-ID: <71790001@hplvec.LVLD.HP.COM>
- Organization: Hewlett-Packard Co., Loveland, CO
- 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
- Newsgroups: comp.std.c
- References: <723345673snx@genesis.demon.co.uk>
- Lines: 20
-
- In comp.std.c, dik@cwi.nl (Dik T. Winter) writes:
-
- > What it comes down to is that << is not a mathematical operation, there
- > is nothing in mathematics that tells us that 16384 << 1 equals 32768.
- > So what is the meaning of:
-
- I'm not so sure about that. Conceptually, the common-usage interpretation
- of the operation a << b can be represented mathematically as a*(2^b).
- I can even propose a hypothetical machine that lacks a true shift instruction
- and actually implements the << and >> operators by such means, especially
- when b is a constant.
-
- Given that potential implementation, it is easy to imagine that INT_MAX << 1
- would generate overflow on such a machine. Now, considering that the ANSI
- standard in general places as few restrictions as possible on implementations
- so as to maximize performance, I'm not sure that there is anything in the
- standard that would judge this implementation as non-conforming.
-
- Art Boyne, boyne@hplvla.lvld.hp.com
- "An innocent bystander bemused by the furor of this discussion"
-