Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!rutgers!lll-lcc!ames!ucbcad!ucbvax!amdcad!tim From: tim@amdcad.UUCP Newsgroups: comp.lang.c Subject: Re: short circuit evaluation Message-ID: <14479@amdcad.UUCP> Date: Sun, 25-Jan-87 13:19:30 EST Article-I.D.: amdcad.14479 Posted: Sun Jan 25 13:19:30 1987 Date-Received: Mon, 26-Jan-87 01:52:50 EST References: <425@bobkat.UUCP> <102600001@datacube> <34@umich.UUCP> <5178@mimsy.UUCP> Reply-To: tim@amdcad.UUCP (Tim Olson) Organization: Advanced Micro Devices, Sunnyvale, California Lines: 30 In article <5178@mimsy.UUCP> chris@mimsy.UUCP (Chris Torek) writes: (OFF is all zeros, ON is all ones) +--------------------------------------- | & 1. Left side evaluated. If OFF, evaluation stops; | result is OFF. If not, right side evaluated, | and both results ANDed. | 2. Left side evaluated. Right side evaluated. | Results ANDed. | 3. Right side evaluated. If OFF, evaluation stops; | result is OFF. If not, left side evaluated, and | both results ANDed. | | | 1. Left side evaluated. If ON, evaluation stops; | result is ON. If not, right side evaluated, | and both results ORed. | 2. Left side evaluated. Right side evaluated. | Results ORed. | 3. Right side evaluated. If ON, evaluation stops; | result is ON. If not, left side evaluated, and | both results ORed. +--------------------------------------- What about if either the left side expression or the right side expression contained a side-effect (or a procedure call, which also may have a side-effect)? These cannot be short-circuited when bit-wise operators are used. -- Tim Olson Advanced Micro Devices "We plan products, not lunches"