In computer logic, an AND gate takes two inputs and produces one output. Under what condition does an AND gate output a 1 (true)?
- Only when both of its inputs are 1
- When at least one of its two inputs is 1
- When exactly one of its two inputs is 1, but not both
- Whenever either input changes value, regardless of what it changes to
Why A? And why not the others?
Correct answer: A. Only when both of its inputs are 1
An AND gate is a basic logic gate used to combine two conditions so that the overall result is only true when both conditions hold, which is why it outputs 1 only when both of its inputs are 1; for any other combination of inputs, its output is 0. This makes it useful for things like 'let the player through only if they have a key AND they have enough energy'. The option describing an output of 1 whenever at least one input is 1 actually describes an OR gate, which is far more permissive and has a completely different truth table from AND. The option describing an output of 1 when exactly one input is 1 but not both describes an XOR (exclusive OR) gate, which specifically excludes the both-true case that AND requires. The option about reacting to any input change is not how a basic AND gate works at all; a plain AND gate has no memory of previous values and depends only on the current values of its inputs, not on whether they changed.
Source: BBC Bitesize GCSE Computer Science: Boolean logic