short circuit evaluation
tim at amdcad.UUCP
tim at amdcad.UUCP
Mon Jan 26 04:19:30 AEST 1987
In article <5178 at mimsy.UUCP> chris at 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"
More information about the Comp.lang.c
mailing list