Signup/Sign In

What are the Logic Gates and How OR, AND, NOR, XNOR, NAND, NOT Gates Work?

Posted in Programming   AUGUST 16, 2022

    Do you know, that computers store decimal numbers in the form of zeros and ones which is called Binary Code?

    If you do then you are probably looking to know about what logic gates are, right? This is the right article for you where you'll understand What is a logic gate, how many of them are there, and how these logic gates work.

    Let's first get to know, What is a Logic gate?

    What is a Logic Gate?

    What is a Logic Gate?

    In computers, transistors are used to store the long string of zeros and ones. Transistors are microscopic electronic switches. You can store the binary numbers by just switching transistors on and off. If you switch on the transistor, it'll store one, and if you switch off it then it'll store zero.

    Alright, you know how numbers are stored but how can you perform addition, subtraction, multiplication, and division using only electric currents?

    A logic gate is an answer to this question. Computers use these logic gates to perform these actions.

    A logic gate is a simple circuit with two inputs and an output. Logic gates do a comparison of two incoming currents and send a new outgoing electric current. A logic gate is like a watchman of a building who allows people to enter the building only if they pass certain tests or conditions.

    There are various Logic gates but the most common Logic gates are AND, OR, NOT, XOR, NAND, and NOR. Let's get to know each of them and how they work. We'll start off with the common ones like OR and AND.

    OR

    OR Logic gate

    An OR logic gate is a very simple logic gate. It says that if any of the inputs are true or both inputs are true then the output will also be true, if both the inputs are false then the output is also false.4

    All of the logic gates don't have two inputs, as you can see NOT gate doesn't have two inputs.

    Observe the below flowchart which explains the working of the OR gate. In the flowchart, 0 represents false and 1 represents true.

    (0 : false, 1 : true)
    0 + 0 => 0
    0 + 1 => 1
    1 + 0 => 1
    1 + 1 => 1

    Notice in the above flowchart that if any of the input is true then the output is also true. The output is false only when both of the inputs are false.

    AND

    AND Logic gate

    The AND gate is a simple logic gate with two inputs and an output. It says that if both inputs are true then the output is true, if any of the inputs is false then it will result in false output.

    0 + 0 => 0
    0 + 1 => 0
    1 + 0 => 0
    1 + 1 => 1

    Note that only one output is true where both the inputs are true.

    XOR

    XOR Logic gate

    The XOR gate is Exclusive OR which is also called EOR or EXOR. The XOR gate also has the same number of inputs and output. This logic gate works like this-

    0 + 0 => 0
    0 + 1 => 1
    1 + 0 => 1
    1 + 1 => 0

    Here, the input needs to be exclusive. As you can see in the above flowchart, the output is false where both the inputs are true.

    NOR

    NOR Logic Gate

    The NOR gate is a NOT-OR gate which is a bit similar to the NOT gate. It's complex but it says that anything which is not an OR-situation result in a true outcome and the rest results in a false outcome.

    0 + 0 => 1
    0 + 1 => 0
    1 + 0 => 0
    1 + 1 => 0

    Notice where both the inputs are false which is not an OR situation that results in true.

    NAND

    NAND Logic Gate

    Like the NOR gate, NAND is NOT-AND gate. It says that everything that is AND situation results in false.

    0 + 0 => 1
    0 + 1 => 1
    1 + 0 => 1
    1 + 1 => 0

    In the above flowchart, both true inputs are AND situation that results in false.

    XNOR

    XNOR Logic Gate

    The XNOR gate is a combination of OR, NOR, and XOR gates. It's also called Exclusive NOT-OR or Exclusive NOR gate. The following flowchart explains the logic :

    0 + 0 => 1
    0 + 1 => 0
    1 + 0 => 0
    1 + 1 => 1

    NOT

    NOT Logic gate

    The NOT gate is the reverse of every input. As we've discussed earlier, NOT gate has only one input.

    0 => 1
    1 => 0

    true will result in false and vice versa.

    Conclusion

    Alright, you know that Logic gate is nothing but a clever electric circuit that has two inputs and one output. We discussed every logic gate and how it works.

    About the author:
    Proficient in Java, Python, and web development; has a knack for writing clearly about complex topics. Dedicated to giving readers the tools they need to learn more about computer science and technology.
    Tags:logic-gatecomputer-network
    IF YOU LIKE IT, THEN SHARE IT
     

    RELATED POSTS