The Boolean data type has only two values: true or false. These values are used to control the flow of the execution of programs. Boolean values are found by comparing other data values. The results of these comparisons may be combined in Boolean expressions.
Many electronic circuits have to make decisions. They look at two or more inputs and use these to determine the outputs from the circuit. The process of doing this uses electronic logic, which is based on digital switches called gates.
Logic gates allow an electronic system to make a decision based on a number of its inputs. They are digital electronic devices. Each input and output of the gates must be one of two states:
A single digital signal can be either on or off - for example, a light with one switch can be on or off. However, if there is more than one signal, there are more than two possible states. For example, if two signals are present there are four possible combinations: on/on, on/off, off/on and off/off.
In a logic gate, each combination can be made to produce a different outcome. Binary numbers reflect the two states - on and off, 1 and 0, true and false - within CPU transistors. Logic gate calculations can also be represented as truth tables.